Merge pull request #1574 from normanjaeckel/Slides

Added list slides for motions and assignments.
This commit is contained in:
Norman Jäckel 2015-06-28 19:48:34 +02:00
commit 2b727cc617
5 changed files with 114 additions and 17 deletions

View File

@ -10,11 +10,39 @@ from .views import ItemViewSet
class ItemListSlide(ProjectorElement):
"""
Slide definitions for the agenda.
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.
"""
name = 'agenda/agenda'
name = 'agenda/item-list'
def get_context(self):
pk = self.config_entry.get('id')
if pk is None:
# Root list slide.
context = {'tree': self.config_entry.get('tree', False)}
else:
# Children slide.
if not Item.objects.filter(pk=pk).exists():
raise ProjectorException(_('Item does not exist.'))
context = {'id': pk, 'tree': self.config_entry.get('tree', False)}
return context
def get_requirements(self, config_entry):
pk = config_entry.get('id', 'tree')
if pk is None or self.config_entry.get('tree', False):
# 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.
yield ProjectorRequirement(
view_class=ItemViewSet,
view_action='list')
@ -24,13 +52,17 @@ class ItemDetailSlide(ProjectorElement):
"""
Slide definitions for Item model.
To activate this slide as list of speakers slide, set 'list_of_speakers'
true.
This is only for detail slides. You have to set 'id'.
To activate a detail slide as list of speakers slide, set 'id' and set
'list_of_speakers' true.
"""
name = 'agenda/item'
name = 'agenda/item-detail'
def get_context(self):
pk = self.config_entry.get('id')
if pk is None:
raise ProjectorException(_('Id must not be None.'))
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)}
@ -38,6 +70,7 @@ class ItemDetailSlide(ProjectorElement):
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
# Detail slide.
try:
item = Item.objects.get(pk=pk)
except Item.DoesNotExist:

View File

@ -8,21 +8,35 @@ from .models import Assignment
from .views import AssignmentViewSet
class AssignmentDetailSlide(ProjectorElement):
class AssignmentSlide(ProjectorElement):
"""
Slide definitions for assignment model.
Slide definitions for Assignment model.
Set 'id' to get a detail slide. Omit it to get a list slide.
"""
name = 'assignments/assignment'
def get_context(self):
pk = self.config_entry.get('id')
if not Assignment.objects.filter(pk=pk).exists():
raise ProjectorException(_('Assignment does not exist.'))
return {'id': pk}
if pk is None:
# List slide.
context = None
else:
# Detail slide.
if not Assignment.objects.filter(pk=pk).exists():
raise ProjectorException(_('Assignment does not exist.'))
context = {'id': pk}
return context
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
if pk is None:
# List slide. Related objects like users and tags are not unlocked.
yield ProjectorRequirement(
view_class=AssignmentViewSet,
view_action='list')
else:
# Detail slide.
try:
assignment = Assignment.objects.get(pk=pk)
except Assignment.DoesNotExist:

View File

@ -6,6 +6,10 @@ class MediafileAppConfig(AppConfig):
verbose_name = 'OpenSlides Mediafiles'
def ready(self):
# Load projector elements.
# Do this by just importing all from these files.
from . import projector # noqa
# Import all required stuff.
from openslides.utils.rest_api import router
from .views import MediafileViewSet

View File

@ -0,0 +1,32 @@
from django.utils.translation import ugettext as _
from openslides.core.exceptions import ProjectorException
from openslides.utils.projector import ProjectorElement, ProjectorRequirement
from .models import Mediafile
from .views import MediafileViewSet
class MediafileSlide(ProjectorElement):
"""
Slide definitions for Mediafile model.
"""
name = 'mediafiles/mediafile'
def get_context(self):
pk = self.config_entry.get('id')
try:
mediafile = Mediafile.objects.get(pk=pk)
except Mediafile.DoesNotExist:
raise ProjectorException(_('File does not exist.'))
if not (mediafile.is_presentable and mediafile.filetype == 'application/pdf'):
raise ProjectorException(_('File is not presentable.'))
return {'id': pk}
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
yield ProjectorRequirement(
view_class=MediafileViewSet,
view_action='retrieve',
pk=str(pk))

View File

@ -8,21 +8,35 @@ from .models import Motion
from .views import CategoryViewSet, MotionViewSet, WorkflowViewSet
class MotionDetailSlide(ProjectorElement):
class MotionSlide(ProjectorElement):
"""
Slide definitions for motion model.
Slide definitions for Motion model.
Set 'id' to get a detail slide. Omit it to get a list slide.
"""
name = 'motions/motion'
def get_context(self):
pk = self.config_entry.get('id')
if not Motion.objects.filter(pk=pk).exists():
raise ProjectorException(_('Motion does not exist.'))
return {'id': pk}
if pk is None:
# List slide.
context = None
else:
# Detail slide.
if not Motion.objects.filter(pk=pk).exists():
raise ProjectorException(_('Motion does not exist.'))
context = {'id': pk}
return context
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
if pk is None:
# List slide. Related objects like users and tags are not unlocked.
yield ProjectorRequirement(
view_class=MotionViewSet,
view_action='list')
else:
# Detail slide.
try:
motion = Motion.objects.get(pk=pk)
except Motion.DoesNotExist: