#255 fixed assignment-poll delete message
This commit is contained in:
parent
8d4df3236b
commit
ebc81d9236
@ -308,6 +308,9 @@ class AssignmentPollDelete(DeleteView):
|
|||||||
def get_redirect_url(self, **kwargs):
|
def get_redirect_url(self, **kwargs):
|
||||||
return reverse('assignment_view', args=[self.assignment.id])
|
return reverse('assignment_view', args=[self.assignment.id])
|
||||||
|
|
||||||
|
def get_success_message(self):
|
||||||
|
return _('Ballot was successfully deleted.') % self.object
|
||||||
|
|
||||||
|
|
||||||
class AssignmentPDF(PDFView):
|
class AssignmentPDF(PDFView):
|
||||||
permission_required = 'assignment.can_see_assignment'
|
permission_required = 'assignment.can_see_assignment'
|
||||||
|
@ -199,21 +199,25 @@ class CreateView(PermissionMixin, _CreateView):
|
|||||||
|
|
||||||
|
|
||||||
class DeleteView(RedirectView, SingleObjectMixin):
|
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):
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
self.confirm_form(request, self.object)
|
self.confirm_form(request, self.object)
|
||||||
|
|
||||||
def pre_post_redirect(self, request, *args, **kwargs):
|
def pre_post_redirect(self, request, *args, **kwargs):
|
||||||
self.object.delete()
|
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):
|
def get(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
return super(DeleteView, self).get(request, *args, **kwargs)
|
return super(DeleteView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def confirm_form(self, request, object, name=None):
|
def confirm_form(self, request, object):
|
||||||
if name is None:
|
self.gen_confirm_form(request, self.get_confirm_question(), object.get_absolute_url('delete'))
|
||||||
name = object
|
|
||||||
self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'))
|
|
||||||
|
|
||||||
def gen_confirm_form(self, request, message, url):
|
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")))
|
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")))
|
||||||
|
Loading…
Reference in New Issue
Block a user