2017-08-30 00:07:54 +02:00
|
|
|
from typing import Generator, Type
|
|
|
|
|
2016-09-17 22:26:23 +02:00
|
|
|
from ..core.exceptions import ProjectorException
|
|
|
|
from ..utils.projector import ProjectorElement
|
2018-08-22 07:59:22 +02:00
|
|
|
from .models import Motion, MotionBlock
|
2015-06-24 22:11:54 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
2016-10-01 20:42:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MotionBlockSlide(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Slide definitions for a block of motions (MotionBlock model).
|
|
|
|
"""
|
|
|
|
name = 'motions/motion-block'
|
|
|
|
|
|
|
|
def check_data(self):
|
|
|
|
if not MotionBlock.objects.filter(pk=self.config_entry.get('id')).exists():
|
|
|
|
raise ProjectorException('MotionBlock does not exist.')
|
|
|
|
|
|
|
|
def update_data(self):
|
|
|
|
data = None
|
|
|
|
try:
|
|
|
|
motion_block = MotionBlock.objects.get(pk=self.config_entry.get('id'))
|
|
|
|
except MotionBlock.DoesNotExist:
|
|
|
|
# MotionBlock does not exist, so just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
data = {'agenda_item_id': motion_block.agenda_item_id}
|
|
|
|
return data
|
2017-08-30 00:07:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
|
|
|
|
yield MotionSlide
|
|
|
|
yield MotionBlockSlide
|