diff --git a/openslides/motion/urls.py b/openslides/motion/urls.py index 6c7956c60..177a5b04f 100644 --- a/openslides/motion/urls.py +++ b/openslides/motion/urls.py @@ -99,12 +99,12 @@ urlpatterns = patterns('openslides.motion.views', ), url(r'^(?P\d+)/support/$', - SupportView.as_view(unsupport=False, answer_url='support/'), + SupportView.as_view(support=True), name='motion_support', ), url(r'^(?P\d+)/unsupport/$', - SupportView.as_view(unsupport=True, answer_url='unsupport/'), + SupportView.as_view(support=False), name='motion_unsupport', ), diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 0ef1f140f..c6d902602 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -371,11 +371,10 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView): permission_required = 'motion.can_support_motion' model = Motion pk_url_kwarg = 'motion_id' - unsupport = False # Must be given in SupportView.as_view() - answer_url = None # Must be given in SupportView.as_view() + support = True def get_question(self): - if not self.unsupport: + if self.support: return _('Do you really want to support this motion?') else: return _('Do you really want to unsupport this motion?') @@ -385,7 +384,7 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView): allowed_actions = motion.get_allowed_actions(request.user) if not self.get_answer().lower() == 'yes': return - if not self.unsupport: + if self.support: if 'support' in allowed_actions: motion.support(person=request.user) messages.success( @@ -405,12 +404,19 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView): else: messages.error( request, - _('You can not support this motion.')) - + _('You can not unsupport this motion.')) def get_redirect_url(self, **kwargs): return reverse('motion_view', args=[kwargs[self.pk_url_kwarg]]) + def get_answer_url(self): + if self.support: + answer_url = 'motion_support' + else: + answer_url = 'motion_unsupport' + return reverse(answer_url, args=[self.kwargs[self.pk_url_kwarg]]) + + @permission_required('motion.can_manage_motion') @template('motion/view.html') def gen_poll(request, motion_id):