Added agenda slides.

This commit is contained in:
Norman Jäckel 2015-06-24 23:36:36 +02:00
parent fe16afa1a7
commit 6da0d41e50
3 changed files with 65 additions and 1 deletions

View File

@ -6,6 +6,10 @@ class AgendaAppConfig(AppConfig):
verbose_name = 'OpenSlides Agenda'
def ready(self):
# Load projector elements.
# Do this by just importing all from these files.
from . import projector # noqa
# Import all required stuff.
from django.db.models.signals import pre_delete
from openslides.config.signals import config_signal

View File

@ -0,0 +1,60 @@
from django.utils.translation import ugettext as _
from openslides.core.exceptions import ProjectorException
from openslides.core.views import TagViewSet
from openslides.utils.projector import ProjectorElement, ProjectorRequirement
from .models import Item
from .views import ItemViewSet
class ItemListSlide(ProjectorElement):
"""
Slide definitions for the agenda.
"""
name = 'agenda/agenda'
def get_requirements(self, config_entry):
yield ProjectorRequirement(
view_class=ItemViewSet,
view_action='list')
class ItemDetailSlide(ProjectorElement):
"""
Slide definitions for Item model.
To activate this slide as list of speakers slide, set 'list_of_speakers'
true.
"""
name = 'agenda/item'
def get_context(self):
pk = self.config_entry.get('id')
if not Item.objects.filter(pk=pk).exists():
raise ProjectorException(_('Item does not exist.'))
return {'id': pk, 'list_of_speakers': self.config_entry.get('list_of_speakers', False)}
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
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))
for speaker in item.speaker_set.all():
yield ProjectorRequirement(
view_class=speaker.user.get_view_class(),
view_action='retrieve',
pk=str(speaker.user_id))
for tag in item.tags.all():
yield ProjectorRequirement(
view_class=TagViewSet,
view_action='retrieve',
pk=str(tag.pk))

View File

@ -43,7 +43,7 @@ class AssignmentDetailSlide(ProjectorElement):
yield ProjectorRequirement(
view_class=option.candidate.get_view_class(),
view_action='retrieve',
pk=str(option.candidate.pk))
pk=str(option.candidate_id))
for tag in assignment.tags.all():
yield ProjectorRequirement(
view_class=TagViewSet,