OpenSlides/openslides/topics/projector.py

33 lines
880 B
Python
Raw Normal View History

from typing import Generator, Type
from ..core.exceptions import ProjectorException
from ..utils.projector import ProjectorElement
from .models import Topic
class TopicSlide(ProjectorElement):
"""
Slide definitions for topic model.
"""
2019-01-06 16:22:33 +01:00
name = "topics/topic"
def check_data(self):
2019-01-06 16:22:33 +01:00
if not Topic.objects.filter(pk=self.config_entry.get("id")).exists():
raise ProjectorException("Topic does not exist.")
2016-10-05 18:25:50 +02:00
def update_data(self):
data = None
try:
2019-01-06 16:22:33 +01:00
topic = Topic.objects.get(pk=self.config_entry.get("id"))
2016-10-05 18:25:50 +02:00
except Topic.DoesNotExist:
# Topic does not exist, so just do nothing.
pass
else:
2019-01-06 16:22:33 +01:00
data = {"agenda_item_id": topic.agenda_item_id}
2016-10-05 18:25:50 +02:00
return data
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
yield TopicSlide