2017-08-30 00:07:54 +02:00
|
|
|
from typing import Generator, Type
|
|
|
|
|
2016-09-17 22:26:23 +02:00
|
|
|
from ..utils.projector import ProjectorElement
|
2015-02-18 01:45:39 +01:00
|
|
|
from .exceptions import ProjectorException
|
2016-10-21 11:05:24 +02:00
|
|
|
from .models import Countdown, ProjectorMessage
|
2015-06-12 21:08:57 +02:00
|
|
|
|
2015-02-18 01:45:39 +01:00
|
|
|
|
|
|
|
class Clock(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Clock on the projector.
|
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "core/clock"
|
2015-02-18 01:45:39 +01:00
|
|
|
|
|
|
|
|
2016-10-21 11:05:24 +02:00
|
|
|
class CountdownElement(ProjectorElement):
|
2015-02-18 01:45:39 +01:00
|
|
|
"""
|
2016-10-21 11:05:24 +02:00
|
|
|
Countdown slide for the projector.
|
2015-02-18 01:45:39 +01:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "core/countdown"
|
2015-02-18 01:45:39 +01:00
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
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.")
|
2016-10-21 11:05:24 +02:00
|
|
|
|
2015-02-18 01:45:39 +01:00
|
|
|
|
2016-10-21 11:05:24 +02:00
|
|
|
class ProjectorMessageElement(ProjectorElement):
|
2015-02-18 01:45:39 +01:00
|
|
|
"""
|
|
|
|
Short message on the projector. Rendered as overlay.
|
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "core/projector-message"
|
2015-02-18 01:45:39 +01:00
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
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.")
|
2016-10-21 11:05:24 +02:00
|
|
|
|
2017-08-30 00:07:54 +02:00
|
|
|
|
|
|
|
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
|
|
|
|
yield Clock
|
|
|
|
yield CountdownElement
|
|
|
|
yield ProjectorMessageElement
|