Fixed wrong deletion if user clicks "no" in confirm form.
This commit is contained in:
parent
0c5459f96e
commit
82e35bebff
@ -145,8 +145,9 @@ def edit(request, assignment_id=None):
|
||||
def delete(request, assignment_id):
|
||||
assignment = Assignment.objects.get(pk=assignment_id)
|
||||
if request.method == 'POST':
|
||||
assignment.delete()
|
||||
messages.success(request, _('Election <b>%s</b> was successfully deleted.') % assignment)
|
||||
if 'submit' in request.POST:
|
||||
assignment.delete()
|
||||
messages.success(request, _('Election <b>%s</b> was successfully deleted.') % assignment)
|
||||
else:
|
||||
del_confirm_form(request, assignment)
|
||||
return redirect(reverse('assignment_overview'))
|
||||
@ -204,16 +205,17 @@ def delother(request, assignment_id, user_id):
|
||||
is_blocked = assignment.is_blocked(person)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
assignment.delrun(person, blocked=False)
|
||||
except Exception, e:
|
||||
messages.error(request, e)
|
||||
else:
|
||||
if not is_blocked:
|
||||
message = _("Candidate <b>%s</b> was withdrawn successfully.") % person
|
||||
if 'submit' in request.POST:
|
||||
try:
|
||||
assignment.delrun(person, blocked=False)
|
||||
except Exception, e:
|
||||
messages.error(request, e)
|
||||
else:
|
||||
message = _("<b>%s</b> was unblocked successfully.") % person
|
||||
messages.success(request, message)
|
||||
if not is_blocked:
|
||||
message = _("Candidate <b>%s</b> was withdrawn successfully.") % person
|
||||
else:
|
||||
message = _("<b>%s</b> was unblocked successfully.") % person
|
||||
messages.success(request, message)
|
||||
else:
|
||||
if not is_blocked:
|
||||
message = _("Do you really want to withdraw <b>%s</b> from the election?") % person
|
||||
|
@ -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")))
|
||||
|
Loading…
Reference in New Issue
Block a user