Block supporting, unsupporting and creation of poll in some states
This commit is contained in:
parent
fb82a1787b
commit
ac41a02ac5
@ -30,7 +30,7 @@ from openslides.projector.api import register_slidemodel
|
|||||||
from openslides.projector.models import SlideMixin
|
from openslides.projector.models import SlideMixin
|
||||||
from openslides.agenda.models import Item
|
from openslides.agenda.models import Item
|
||||||
|
|
||||||
from .workflow import motion_workflow_choices, get_state, State
|
from .workflow import motion_workflow_choices, get_state, State, WorkflowError
|
||||||
|
|
||||||
|
|
||||||
# TODO: Save submitter and supporter in the same table
|
# TODO: Save submitter and supporter in the same table
|
||||||
@ -254,15 +254,19 @@ class Motion(SlideMixin, models.Model):
|
|||||||
"""
|
"""
|
||||||
Add a Supporter to the list of supporters of the motion.
|
Add a Supporter to the list of supporters of the motion.
|
||||||
"""
|
"""
|
||||||
|
if self.state.support:
|
||||||
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))
|
||||||
# TODO: Raise a precise exception for the view in else-clause
|
# TODO: Raise a precise exception for the view in else-clause
|
||||||
|
else:
|
||||||
|
raise WorkflowError("You can not support a motion in state %s" % self.state.name)
|
||||||
|
|
||||||
def unsupport(self, person):
|
def unsupport(self, person):
|
||||||
"""
|
"""
|
||||||
remove a supporter from the list of supporters of the motion
|
Remove a supporter from the list of supporters of the motion
|
||||||
"""
|
"""
|
||||||
|
if self.state.support:
|
||||||
try:
|
try:
|
||||||
self.supporter.filter(person=person).delete()
|
self.supporter.filter(person=person).delete()
|
||||||
except MotionSupporter.DoesNotExist:
|
except MotionSupporter.DoesNotExist:
|
||||||
@ -270,16 +274,21 @@ class Motion(SlideMixin, models.Model):
|
|||||||
pass
|
pass
|
||||||
#else:
|
#else:
|
||||||
#self.writelog(_("Supporter: -%s") % (person))
|
#self.writelog(_("Supporter: -%s") % (person))
|
||||||
|
else:
|
||||||
|
raise WorkflowError("You can not unsupport a motion in state %s" % self.state.name)
|
||||||
|
|
||||||
def create_poll(self):
|
def create_poll(self):
|
||||||
"""
|
"""
|
||||||
Create a new poll for this motion
|
Create a new poll for this motion
|
||||||
"""
|
"""
|
||||||
# TODO: auto increment the poll_number in the Database
|
# TODO: auto increment the poll_number in the Database
|
||||||
|
if self.state.poll:
|
||||||
poll_number = self.polls.aggregate(Max('poll_number'))['poll_number__max'] or 0
|
poll_number = self.polls.aggregate(Max('poll_number'))['poll_number__max'] or 0
|
||||||
poll = MotionPoll.objects.create(motion=self, poll_number=poll_number + 1)
|
poll = MotionPoll.objects.create(motion=self, poll_number=poll_number + 1)
|
||||||
poll.set_options()
|
poll.set_options()
|
||||||
return poll
|
return poll
|
||||||
|
else:
|
||||||
|
raise WorkflowError("You can not create a poll in state %s" % self.state.name)
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
"""
|
"""
|
||||||
|
@ -18,6 +18,9 @@ class State(object):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
class WorkflowError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def motion_workflow_choices():
|
def motion_workflow_choices():
|
||||||
for workflow in settings.MOTION_WORKFLOW:
|
for workflow in settings.MOTION_WORKFLOW:
|
||||||
|
Loading…
Reference in New Issue
Block a user