Fixt problems with the permission of supporting and unsupporting a motion
Ticket #377
This commit is contained in:
parent
7dcc2374f4
commit
2e41dcdefe
@ -258,11 +258,8 @@ class Motion(models.Model, SlideMixin):
|
||||
"""
|
||||
if person == self.submitter:
|
||||
# TODO: Use own Exception
|
||||
raise NameError('Supporter can not be the submitter of a ' \
|
||||
raise NameError('Supporter can not be the submitter of a '
|
||||
'motion.')
|
||||
if self.permitted is not None:
|
||||
# TODO: Use own Exception
|
||||
raise NameError('This motion is already permitted.')
|
||||
if not self.is_supporter(person):
|
||||
MotionSupporter(motion=self, person=person).save()
|
||||
self.writelog(_("Supporter: +%s") % (person))
|
||||
@ -272,9 +269,6 @@ class Motion(models.Model, SlideMixin):
|
||||
"""
|
||||
remove a supporter from the list of supporters of the motion
|
||||
"""
|
||||
if self.permitted is not None:
|
||||
# TODO: Use own Exception
|
||||
raise NameError('This motion is already permitted.')
|
||||
try:
|
||||
object = self.motionsupporter_set.get(person=person).delete()
|
||||
except MotionSupporter.DoesNotExist:
|
||||
|
@ -13,7 +13,7 @@
|
||||
from django.conf.urls.defaults import url, patterns
|
||||
|
||||
from openslides.motion.views import (MotionDelete, ViewPoll,
|
||||
MotionPDF, MotionPollPDF, CreateAgendaItem)
|
||||
MotionPDF, MotionPollPDF, CreateAgendaItem, SupportView)
|
||||
|
||||
urlpatterns = patterns('openslides.motion.views',
|
||||
url(r'^$',
|
||||
@ -99,12 +99,12 @@ urlpatterns = patterns('openslides.motion.views',
|
||||
),
|
||||
|
||||
url(r'^(?P<motion_id>\d+)/support/$',
|
||||
'support',
|
||||
SupportView.as_view(unsupport=False, answer_url='support/'),
|
||||
name='motion_support',
|
||||
),
|
||||
|
||||
url(r'^(?P<motion_id>\d+)/unsupport/$',
|
||||
'unsupport',
|
||||
SupportView.as_view(unsupport=True, answer_url='unsupport/'),
|
||||
name='motion_unsupport',
|
||||
),
|
||||
|
||||
|
@ -381,14 +381,32 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
|
||||
return _('Do you really want to unsupport this motion?')
|
||||
|
||||
def pre_post_redirect(self, request, *args, **kwargs):
|
||||
if self.get_answer().lower() == 'yes':
|
||||
if not self.unsupport:
|
||||
self.get_object().support(person=request.user)
|
||||
self.success_message = _("You have supported this motion successfully.")
|
||||
motion = self.get_object()
|
||||
allowed_actions = motion.get_allowed_actions(request.user)
|
||||
if not self.get_answer().lower() == 'yes':
|
||||
return
|
||||
if not self.unsupport:
|
||||
if 'support' in allowed_actions:
|
||||
motion.support(person=request.user)
|
||||
messages.success(
|
||||
request,
|
||||
_("You have supported this motion successfully."))
|
||||
|
||||
else:
|
||||
messages.error(
|
||||
request,
|
||||
_('You can not support this motion.'))
|
||||
else:
|
||||
if 'unsupport' in allowed_actions:
|
||||
self.get_object().unsupport(person=request.user)
|
||||
self.success_message = _("You have unsupported this motion successfully.")
|
||||
messages.success(request, self.success_message)
|
||||
messages.success(
|
||||
request,
|
||||
_("You have unsupported this motion successfully."))
|
||||
else:
|
||||
messages.error(
|
||||
request,
|
||||
_('You can not support this motion.'))
|
||||
|
||||
|
||||
def get_redirect_url(self, **kwargs):
|
||||
return reverse('motion_view', args=[kwargs[self.pk_url_kwarg]])
|
||||
|
Loading…
Reference in New Issue
Block a user