aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-04-07 20:55:36 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-12-21 19:43:13 +0200
commitee619af4367224dbc271962120493b2326a15a00 (patch)
tree77d5bc959fc7f8c561ba8d07456b30282418ad6b
parent0b5b97c74803d1c8f06b380ad7c575109f9730ae (diff)
Add a confirmation screen when deleting submission
-rw-r--r--app.py13
-rw-r--r--templates/voter_confirm_delete.html.j212
2 files changed, 25 insertions, 0 deletions
diff --git a/app.py b/app.py
index 190b0c8..8ca7c44 100644
--- a/app.py
+++ b/app.py
@@ -226,6 +226,19 @@ def delete_voter(id):
if not validate_uuid(id):
return error_page("Invalid poll ID", 400)
+ voter_code = request.form["voter_code"]
+ voter_name = db.get_voter_name_by_manage_code(voter_code)
+
+ return render_template("voter_confirm_delete.html.j2",
+ voter_name=voter_name,
+ voter_code=voter_code,
+ poll_id=id)
+
+@app.post("/poll/<id>/confirm_delete_voter")
+def confirm_delete_voter(id):
+ if not validate_uuid(id):
+ return error_page("Invalid poll ID", 400)
+
voter_manage_code = request.form["voter_code"]
voter_name = db.get_voter_name_by_manage_code(voter_manage_code)
diff --git a/templates/voter_confirm_delete.html.j2 b/templates/voter_confirm_delete.html.j2
new file mode 100644
index 0000000..faa175a
--- /dev/null
+++ b/templates/voter_confirm_delete.html.j2
@@ -0,0 +1,12 @@
+{% extends "base.html.j2" %}
+
+{% block content %}
+<h2>Confirm deletion of voter <span class="contrast">{{ voter_name }}</span></h2>
+
+<p>Are you sure you want to delete the submission by {{ voter_name }}?</p>
+
+<form action="/poll/{{ poll_id }}/confirm_delete_voter" method="post">
+ <input type="hidden" name="voter_code" value="{{ voter_code }}">
+ <input class="red" type="submit" value="Yes, delete it">
+</form>
+{% endblock %}