2015-06-24 23:36:36 +02:00
|
|
|
from openslides.core.exceptions import ProjectorException
|
|
|
|
from openslides.utils.projector import ProjectorElement, ProjectorRequirement
|
|
|
|
|
|
|
|
from .models import Item
|
|
|
|
from .views import ItemViewSet
|
|
|
|
|
|
|
|
|
|
|
|
class ItemListSlide(ProjectorElement):
|
|
|
|
"""
|
2015-06-25 20:36:46 +02:00
|
|
|
Slide definitions for Item model.
|
|
|
|
|
|
|
|
This is only for 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
|
|
|
"""
|
2015-06-25 20:36:46 +02:00
|
|
|
name = 'agenda/item-list'
|
|
|
|
|
|
|
|
def get_context(self):
|
|
|
|
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():
|
2015-11-21 00:00:31 +01:00
|
|
|
raise ProjectorException('Item does not exist.')
|
2015-06-24 23:36:36 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2015-06-25 20:36:46 +02:00
|
|
|
pk = config_entry.get('id', 'tree')
|
2015-06-29 15:51:15 +02:00
|
|
|
if pk is None or config_entry.get('tree', False):
|
2015-06-25 20:36:46 +02:00
|
|
|
# Root list slide or slide with tree.
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=ItemViewSet,
|
|
|
|
view_action='tree')
|
|
|
|
|
|
|
|
# Root list slide and children list slide.
|
|
|
|
# Related objects like users and tags are not unlocked.
|
2015-06-24 23:36:36 +02:00
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=ItemViewSet,
|
|
|
|
view_action='list')
|
|
|
|
|
|
|
|
|
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
|
|
|
"""
|
2016-01-09 10:53:43 +01:00
|
|
|
name = 'agenda/list-of-speakers'
|
2015-06-24 23:36:36 +02:00
|
|
|
|
|
|
|
def get_context(self):
|
|
|
|
pk = self.config_entry.get('id')
|
2015-06-25 20:36:46 +02:00
|
|
|
if pk is None:
|
2015-11-21 00:00:31 +01:00
|
|
|
raise ProjectorException('Id must not be None.')
|
2015-06-24 23:36:36 +02:00
|
|
|
if not Item.objects.filter(pk=pk).exists():
|
2015-11-21 00:00:31 +01:00
|
|
|
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:
|
2015-12-11 15:35:41 +01:00
|
|
|
# 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 ProjectorRequirement(
|
|
|
|
view_class=ItemViewSet,
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(item.pk))
|
2015-09-04 18:24:41 +02:00
|
|
|
for speaker in item.speakers.all():
|
2015-06-24 23:36:36 +02:00
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=speaker.user.get_view_class(),
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(speaker.user_id))
|