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
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "motions/motion"
|
2015-06-24 22:11:54 +02:00
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2019-01-06 16:22:33 +01: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:
|
2019-01-06 16:22:33 +01:00
|
|
|
motion = Motion.objects.get(pk=self.config_entry.get("id"))
|
2016-10-05 18:25:50 +02:00
|
|
|
except Motion.DoesNotExist:
|
|
|
|
# Motion does not exist, so just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
2019-01-06 16:22:33 +01:00
|
|
|
data = {"agenda_item_id": motion.agenda_item_id}
|
2016-10-05 18:25:50 +02:00
|
|
|
return data
|
2016-10-01 20:42:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MotionBlockSlide(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Slide definitions for a block of motions (MotionBlock model).
|
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "motions/motion-block"
|
2016-10-01 20:42:44 +02:00
|
|
|
|
|
|
|
def check_data(self):
|
2019-01-06 16:22:33 +01:00
|
|
|
if not MotionBlock.objects.filter(pk=self.config_entry.get("id")).exists():
|
|
|
|
raise ProjectorException("MotionBlock does not exist.")
|
2016-10-01 20:42:44 +02:00
|
|
|
|
|
|
|
def update_data(self):
|
|
|
|
data = None
|
|
|
|
try:
|
2019-01-06 16:22:33 +01:00
|
|
|
motion_block = MotionBlock.objects.get(pk=self.config_entry.get("id"))
|
2016-10-01 20:42:44 +02:00
|
|
|
except MotionBlock.DoesNotExist:
|
|
|
|
# MotionBlock does not exist, so just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
2019-01-06 16:22:33 +01:00
|
|
|
data = {"agenda_item_id": motion_block.agenda_item_id}
|
2016-10-01 20:42:44 +02:00
|
|
|
return data
|
2017-08-30 00:07:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
|
|
|
|
yield MotionSlide
|
|
|
|
yield MotionBlockSlide
|