From b6256b73e0263709533b16f4225fab91b2c56f12 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 1 Feb 2013 13:24:30 +0100 Subject: [PATCH] Changed utils.views.DeleteView --- openslides/utils/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 4051f93e2..a8b8657dd 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -287,10 +287,25 @@ class CreateView(PermissionMixin, UrlMixin, ExtraContextMixin, class DeleteView(SingleObjectMixin, QuestionMixin, RedirectView): + question_url_name = None + success_url_name = None + def get(self, request, *args, **kwargs): self.object = self.get_object() return super(DeleteView, self).get(request, *args, **kwargs) + def get_redirect_url(self, **kwargs): + if self.request.method == 'GET': + if self.question_url_name is not None: + return reverse(self.question_url_name, args=self.get_url_name_args()) + else: + return self.object.get_absolute_url() + else: + return reverse(self.success_url_name, args=self.get_url_name_args()) + + def get_url_name_args(self): + return [self.poll.motion.pk] + def get_question(self): return _('Do you really want to delete %s?') % html_strong(self.object)