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
|
2015-06-24 23:36:36 +02:00
|
|
|
from .models import Item
|
|
|
|
|
|
|
|
|
|
|
|
class ItemListSlide(ProjectorElement):
|
|
|
|
"""
|
2015-06-25 20:36:46 +02:00
|
|
|
Slide definitions for Item model.
|
|
|
|
|
2016-09-17 22:26:23 +02:00
|
|
|
This is only for item list slides.
|
2015-06-25 20:36:46 +02:00
|
|
|
|
|
|
|
Set 'id' to None to get a list slide of all root items. Set 'id' to an
|
|
|
|
integer to get a list slide of the children of the metioned item.
|
|
|
|
|
|
|
|
Additionally set 'tree' to True to get also children of children.
|
2015-06-24 23:36:36 +02:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "agenda/item-list"
|
2015-06-25 20:36:46 +02:00
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2019-01-06 16:22:33 +01:00
|
|
|
pk = self.config_entry.get("id")
|
2015-09-08 14:14:11 +02:00
|
|
|
if pk is not None:
|
2015-06-25 20:36:46 +02:00
|
|
|
# Children slide.
|
|
|
|
if not Item.objects.filter(pk=pk).exists():
|
2019-01-06 16:22:33 +01:00
|
|
|
raise ProjectorException("Item does not exist.")
|
2015-06-24 23:36:36 +02:00
|
|
|
|
|
|
|
|
2016-01-09 10:53:43 +01:00
|
|
|
class ListOfSpeakersSlide(ProjectorElement):
|
2015-06-24 23:36:36 +02:00
|
|
|
"""
|
|
|
|
Slide definitions for Item model.
|
2015-12-11 15:35:41 +01:00
|
|
|
This is only for list of speakers slide. You have to set 'id'.
|
2015-06-24 23:36:36 +02:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "agenda/list-of-speakers"
|
2015-06-24 23:36:36 +02:00
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2019-01-06 16:22:33 +01:00
|
|
|
if not Item.objects.filter(pk=self.config_entry.get("id")).exists():
|
|
|
|
raise ProjectorException("Item does not exist.")
|
2015-06-24 23:36:36 +02:00
|
|
|
|
2016-10-05 18:25:50 +02:00
|
|
|
def update_data(self):
|
2019-01-06 16:22:33 +01:00
|
|
|
return {"agenda_item_id": self.config_entry.get("id")}
|
2016-10-05 18:25:50 +02:00
|
|
|
|
2016-09-12 11:05:34 +02:00
|
|
|
|
2017-02-03 11:54:36 +01:00
|
|
|
class CurrentListOfSpeakersSlide(ProjectorElement):
|
2016-09-12 11:05:34 +02:00
|
|
|
"""
|
2017-02-03 11:54:36 +01:00
|
|
|
Slide for the current list of speakers.
|
2016-10-05 18:25:50 +02:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
name = "agenda/current-list-of-speakers"
|
2017-02-03 11:54:36 +01:00
|
|
|
|
2017-08-30 00:07:54 +02:00
|
|
|
|
|
|
|
def get_projector_elements() -> Generator[Type[ProjectorElement], None, None]:
|
|
|
|
yield ItemListSlide
|
|
|
|
yield ListOfSpeakersSlide
|
|
|
|
yield CurrentListOfSpeakersSlide
|