Remove redundant keyword for the SupportView class

This commit is contained in:
Oskar Hahn 2012-10-25 10:25:59 +02:00
parent 2e41dcdefe
commit 1002ecc6e6
2 changed files with 14 additions and 8 deletions

View File

@ -99,12 +99,12 @@ urlpatterns = patterns('openslides.motion.views',
), ),
url(r'^(?P<motion_id>\d+)/support/$', url(r'^(?P<motion_id>\d+)/support/$',
SupportView.as_view(unsupport=False, answer_url='support/'), SupportView.as_view(support=True),
name='motion_support', name='motion_support',
), ),
url(r'^(?P<motion_id>\d+)/unsupport/$', url(r'^(?P<motion_id>\d+)/unsupport/$',
SupportView.as_view(unsupport=True, answer_url='unsupport/'), SupportView.as_view(support=False),
name='motion_unsupport', name='motion_unsupport',
), ),

View File

@ -371,11 +371,10 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
permission_required = 'motion.can_support_motion' permission_required = 'motion.can_support_motion'
model = Motion model = Motion
pk_url_kwarg = 'motion_id' pk_url_kwarg = 'motion_id'
unsupport = False # Must be given in SupportView.as_view() support = True
answer_url = None # Must be given in SupportView.as_view()
def get_question(self): def get_question(self):
if not self.unsupport: if self.support:
return _('Do you really want to support this motion?') return _('Do you really want to support this motion?')
else: else:
return _('Do you really want to unsupport this motion?') 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) allowed_actions = motion.get_allowed_actions(request.user)
if not self.get_answer().lower() == 'yes': if not self.get_answer().lower() == 'yes':
return return
if not self.unsupport: if self.support:
if 'support' in allowed_actions: if 'support' in allowed_actions:
motion.support(person=request.user) motion.support(person=request.user)
messages.success( messages.success(
@ -405,12 +404,19 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
else: else:
messages.error( messages.error(
request, request,
_('You can not support this motion.')) _('You can not unsupport this motion.'))
def get_redirect_url(self, **kwargs): def get_redirect_url(self, **kwargs):
return reverse('motion_view', args=[kwargs[self.pk_url_kwarg]]) 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') @permission_required('motion.can_manage_motion')
@template('motion/view.html') @template('motion/view.html')
def gen_poll(request, motion_id): def gen_poll(request, motion_id):