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:
|
if person == self.submitter:
|
||||||
# TODO: Use own Exception
|
# 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.')
|
'motion.')
|
||||||
if self.permitted is not None:
|
|
||||||
# TODO: Use own Exception
|
|
||||||
raise NameError('This motion is already permitted.')
|
|
||||||
if not self.is_supporter(person):
|
if not self.is_supporter(person):
|
||||||
MotionSupporter(motion=self, person=person).save()
|
MotionSupporter(motion=self, person=person).save()
|
||||||
self.writelog(_("Supporter: +%s") % (person))
|
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
|
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:
|
try:
|
||||||
object = self.motionsupporter_set.get(person=person).delete()
|
object = self.motionsupporter_set.get(person=person).delete()
|
||||||
except MotionSupporter.DoesNotExist:
|
except MotionSupporter.DoesNotExist:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
from django.conf.urls.defaults import url, patterns
|
from django.conf.urls.defaults import url, patterns
|
||||||
|
|
||||||
from openslides.motion.views import (MotionDelete, ViewPoll,
|
from openslides.motion.views import (MotionDelete, ViewPoll,
|
||||||
MotionPDF, MotionPollPDF, CreateAgendaItem)
|
MotionPDF, MotionPollPDF, CreateAgendaItem, SupportView)
|
||||||
|
|
||||||
urlpatterns = patterns('openslides.motion.views',
|
urlpatterns = patterns('openslides.motion.views',
|
||||||
url(r'^$',
|
url(r'^$',
|
||||||
@ -99,12 +99,12 @@ urlpatterns = patterns('openslides.motion.views',
|
|||||||
),
|
),
|
||||||
|
|
||||||
url(r'^(?P<motion_id>\d+)/support/$',
|
url(r'^(?P<motion_id>\d+)/support/$',
|
||||||
'support',
|
SupportView.as_view(unsupport=False, answer_url='support/'),
|
||||||
name='motion_support',
|
name='motion_support',
|
||||||
),
|
),
|
||||||
|
|
||||||
url(r'^(?P<motion_id>\d+)/unsupport/$',
|
url(r'^(?P<motion_id>\d+)/unsupport/$',
|
||||||
'unsupport',
|
SupportView.as_view(unsupport=True, answer_url='unsupport/'),
|
||||||
name='motion_unsupport',
|
name='motion_unsupport',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -381,14 +381,32 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
|
|||||||
return _('Do you really want to unsupport this motion?')
|
return _('Do you really want to unsupport this motion?')
|
||||||
|
|
||||||
def pre_post_redirect(self, request, *args, **kwargs):
|
def pre_post_redirect(self, request, *args, **kwargs):
|
||||||
if self.get_answer().lower() == 'yes':
|
motion = self.get_object()
|
||||||
if not self.unsupport:
|
allowed_actions = motion.get_allowed_actions(request.user)
|
||||||
self.get_object().support(person=request.user)
|
if not self.get_answer().lower() == 'yes':
|
||||||
self.success_message = _("You have supported this motion successfully.")
|
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:
|
else:
|
||||||
|
messages.error(
|
||||||
|
request,
|
||||||
|
_('You can not support this motion.'))
|
||||||
|
else:
|
||||||
|
if 'unsupport' in allowed_actions:
|
||||||
self.get_object().unsupport(person=request.user)
|
self.get_object().unsupport(person=request.user)
|
||||||
self.success_message = _("You have unsupported this motion successfully.")
|
messages.success(
|
||||||
messages.success(request, self.success_message)
|
request,
|
||||||
|
_("You have unsupported this motion successfully."))
|
||||||
|
else:
|
||||||
|
messages.error(
|
||||||
|
request,
|
||||||
|
_('You can not support 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]])
|
||||||
|
Loading…
Reference in New Issue
Block a user