2016-09-17 22:26:23 +02:00
|
|
|
from ..core.exceptions import ProjectorException
|
2016-09-30 23:39:42 +02:00
|
|
|
from ..utils.collection import CollectionElement
|
2016-09-17 22:26:23 +02:00
|
|
|
from ..utils.projector import ProjectorElement
|
2015-06-24 22:11:54 +02:00
|
|
|
from .models import Motion
|
|
|
|
|
|
|
|
|
2015-06-25 20:36:46 +02:00
|
|
|
class MotionSlide(ProjectorElement):
|
2015-06-24 22:11:54 +02:00
|
|
|
"""
|
2015-06-25 20:36:46 +02:00
|
|
|
Slide definitions for Motion model.
|
2015-06-24 22:11:54 +02:00
|
|
|
"""
|
|
|
|
name = 'motions/motion'
|
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2016-09-17 22:26:23 +02:00
|
|
|
if not Motion.objects.filter(pk=self.config_entry.get('id')).exists():
|
|
|
|
raise ProjectorException('Motion does not exist.')
|
2015-06-24 22:11:54 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2016-09-17 22:26:23 +02:00
|
|
|
try:
|
|
|
|
motion = Motion.objects.get(pk=config_entry.get('id'))
|
|
|
|
except Motion.DoesNotExist:
|
|
|
|
# Motion does not exist. Just do nothing.
|
|
|
|
pass
|
2015-06-25 20:36:46 +02:00
|
|
|
else:
|
2016-09-17 22:26:23 +02:00
|
|
|
yield motion
|
|
|
|
yield motion.agenda_item
|
|
|
|
yield motion.state.workflow
|
|
|
|
yield from motion.submitters.all()
|
|
|
|
yield from motion.supporters.all()
|
2016-09-23 13:12:02 +02:00
|
|
|
|
2016-09-30 23:39:42 +02:00
|
|
|
def get_collection_elements_required_for_this(self, collection_element, config_entry):
|
|
|
|
output = super().get_collection_elements_required_for_this(collection_element, config_entry)
|
2016-09-23 13:12:02 +02:00
|
|
|
# Full update if motion changes because then we may have new
|
|
|
|
# submitters or supporters and therefor need new users.
|
|
|
|
#
|
|
|
|
# Add some logic here if we support live changing of workflows later.
|
|
|
|
#
|
2016-09-30 23:39:42 +02:00
|
|
|
if collection_element == CollectionElement.from_values(Motion.get_collection_string(), config_entry.get('id')):
|
|
|
|
output.extend(self.get_requirements_as_collection_elements(config_entry))
|
|
|
|
return output
|
2016-10-05 18:25:50 +02:00
|
|
|
|
|
|
|
def update_data(self):
|
|
|
|
data = None
|
|
|
|
try:
|
|
|
|
motion = Motion.objects.get(pk=self.config_entry.get('id'))
|
|
|
|
except Motion.DoesNotExist:
|
|
|
|
# Motion does not exist, so just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
data = {'agenda_item_id': motion.agenda_item_id}
|
|
|
|
return data
|