diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 9eaa42305..451b24c80 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -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' diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 83dd425b7..5141e19ef 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -199,21 +199,25 @@ class CreateView(PermissionMixin, _CreateView): class DeleteView(RedirectView, SingleObjectMixin): + def get_confirm_question(self): + return _('Do you really want to delete %s?') % self.object + + def get_success_message(self): + return _('Item %s 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 %s 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 %s?') % 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
' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("No")))