OpenSlides/openslides/agenda/projector.py

67 lines
2.3 KiB
Python
Raw Normal View History

from ..core.config import config
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):
"""
Slide definitions for Item model.
This is only for item list slides.
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
"""
name = 'agenda/item-list'
def check_data(self):
pk = self.config_entry.get('id')
2015-09-08 14:14:11 +02:00
if pk is not None:
# Children slide.
if not Item.objects.filter(pk=pk).exists():
raise ProjectorException('Item does not exist.')
2015-06-24 23:36:36 +02:00
def get_requirements(self, config_entry):
yield from Item.objects.all()
2015-06-24 23:36:36 +02:00
class ListOfSpeakersSlide(ProjectorElement):
2015-06-24 23:36:36 +02:00
"""
Slide definitions for Item model.
This is only for list of speakers slide. You have to set 'id'.
2015-06-24 23:36:36 +02:00
"""
name = 'agenda/list-of-speakers'
2015-06-24 23:36:36 +02:00
def check_data(self):
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
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
# List of speakers slide.
2015-06-24 23:36:36 +02:00
try:
item = Item.objects.get(pk=pk)
except Item.DoesNotExist:
# Item does not exist. Just do nothing.
pass
else:
yield item
for speaker in item.speakers.filter(end_time=None):
# Yield current speaker and next speakers
yield speaker.user
query = (item.speakers.exclude(end_time=None)
.order_by('-end_time')[:config['agenda_show_last_speakers']])
for speaker in query:
# Yield last speakers
yield speaker.user
def need_full_update_for_this(self, collection_element):
# Full update if item changes because then we may have new speakers
# and therefor need new users.
return collection_element.collection_string == Item.get_collection_string()