#255 fixed assignment-poll delete message

This commit is contained in:
Oskar Hahn 2012-07-01 17:38:34 +02:00
parent 8d4df3236b
commit ebc81d9236
2 changed files with 12 additions and 5 deletions

View File

@ -308,6 +308,9 @@ class AssignmentPollDelete(DeleteView):
def get_redirect_url(self, **kwargs):
return reverse('assignment_view', args=[self.assignment.id])
def get_success_message(self):
return _('Ballot was successfully deleted.') % self.object
class AssignmentPDF(PDFView):
permission_required = 'assignment.can_see_assignment'

View File

@ -199,21 +199,25 @@ class CreateView(PermissionMixin, _CreateView):
class DeleteView(RedirectView, SingleObjectMixin):
def get_confirm_question(self):
return _('Do you really want to delete <b>%s</b>?') % self.object
def get_success_message(self):
return _('Item <b>%s</b> was successfully deleted.') % self.object
def pre_redirect(self, request, *args, **kwargs):
self.confirm_form(request, self.object)
def pre_post_redirect(self, request, *args, **kwargs):
self.object.delete()
messages.success(request, _("Item <b>%s</b> was successfully deleted.") % self.object)
messages.success(request, self.get_success_message())
def get(self, request, *args, **kwargs):
self.object = self.get_object()
return super(DeleteView, self).get(request, *args, **kwargs)
def confirm_form(self, request, object, name=None):
if name is None:
name = object
self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'))
def confirm_form(self, request, object):
self.gen_confirm_form(request, self.get_confirm_question(), object.get_absolute_url('delete'))
def gen_confirm_form(self, request, message, url):
messages.warning(request, '%s<form action="%s" method="post"><input type="hidden" value="%s" name="csrfmiddlewaretoken"><input type="submit" value="%s" /> <input type="button" value="%s"></form>' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("No")))