OpenSlides/openslides/core/projector.py

44 lines
1.1 KiB
Python
Raw Normal View History

from typing import Generator, Type
from ..utils.projector import ProjectorElement
from .exceptions import ProjectorException
from .models import Countdown, ProjectorMessage
class Clock(ProjectorElement):
"""
Clock on the projector.
"""
2019-01-06 16:22:33 +01:00
name = "core/clock"
class CountdownElement(ProjectorElement):
"""
Countdown slide for the projector.
"""
2019-01-06 16:22:33 +01:00
name = "core/countdown"
def check_data(self):
2019-01-06 16:22:33 +01:00
if not Countdown.objects.filter(pk=self.config_entry.get("id")).exists():
raise ProjectorException("Countdown does not exists.")
class ProjectorMessageElement(ProjectorElement):
"""
Short message on the projector. Rendered as overlay.
"""
2019-01-06 16:22:33 +01:00
name = "core/projector-message"
def check_data(self):
2019-01-06 16:22:33 +01:00
if not ProjectorMessage.objects.filter(pk=self.config_entry.get("id")).exists():
raise ProjectorException("Message does not exists.")
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
yield Clock
yield CountdownElement
yield ProjectorMessageElement