From 31ba70efd10fa937cbb00c18d441f3d48c07a5df Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 11 Mar 2013 21:38:07 +0100 Subject: [PATCH] Category Delete View --- openslides/motion/models.py | 2 ++ openslides/motion/urls.py | 5 +++++ openslides/motion/views.py | 8 ++++++++ openslides/utils/views.py | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 2446747c6..023326f2a 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -535,6 +535,8 @@ class Category(models.Model): def get_absolute_url(self, link='update'): if link == 'update' or link == 'edit': return reverse('motion_category_update', args=[str(self.id)]) + if link == 'delete': + return reverse('motion_category_delete', args=[str(self.id)]) ## class Comment(models.Model): diff --git a/openslides/motion/urls.py b/openslides/motion/urls.py index 06bccb7b2..1fd507ad1 100644 --- a/openslides/motion/urls.py +++ b/openslides/motion/urls.py @@ -119,4 +119,9 @@ urlpatterns = patterns('openslides.motion.views', 'category_update', name='motion_category_update', ), + + url(r'^category/(?P\d+)/del/$', + 'category_delete', + name='motion_category_delete', + ), ) diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 6e6c979bd..d7a760855 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -496,6 +496,14 @@ class CategoryUpdateView(UpdateView): category_update = CategoryUpdateView.as_view() +class CategoryDeleteView(DeleteView): + permission_required = 'motion.can_manage_motion' + model = Category + success_url_name = 'motion_category_list' + +category_delete = CategoryDeleteView.as_view() + + class Config(FormView): """The View for the config tab.""" permission_required = 'config.can_manage_config' diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 928e56767..00bc6b9fa 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -304,7 +304,8 @@ class DeleteView(SingleObjectMixin, QuestionMixin, RedirectView): return super(DeleteView, self).get(request, *args, **kwargs) def get_redirect_url(self, **kwargs): - if self.request.method == 'GET' and self.question_url_name is None: + if self.question_url_name is None and (self.request.method == 'GET' or + self.get_answer() == 'no'): return self.object.get_absolute_url() else: return super(DeleteView, self).get_redirect_url(**kwargs)