Fixed wrong deletion if user clicks "no" in confirm form.

This commit is contained in:
Emanuel Schuetze 2013-02-05 21:31:45 +01:00
parent 0c5459f96e
commit 82e35bebff
2 changed files with 15 additions and 13 deletions

View File

@ -145,6 +145,7 @@ def edit(request, assignment_id=None):
def delete(request, assignment_id):
assignment = Assignment.objects.get(pk=assignment_id)
if request.method == 'POST':
if 'submit' in request.POST:
assignment.delete()
messages.success(request, _('Election <b>%s</b> was successfully deleted.') % assignment)
else:
@ -204,6 +205,7 @@ def delother(request, assignment_id, user_id):
is_blocked = assignment.is_blocked(person)
if request.method == 'POST':
if 'submit' in request.POST:
try:
assignment.delrun(person, blocked=False)
except Exception, e:

View File

@ -38,8 +38,8 @@ def gen_confirm_form(request, message, url):
%s
<form action="%s" method="post">
<input type="hidden" value="%s" name="csrfmiddlewaretoken">
<button type="submit" class="btn btn-mini">%s</button>
<button class="btn btn-mini">%s</button>
<button type="submit" name="submit" class="btn btn-mini">%s</button>
<button name="cancel" class="btn btn-mini">%s</button>
</form>
"""
% (message, url, csrf(request)['csrf_token'], _("Yes"), _("No")))