Added and updated several projector elements (slides).
Added list slides for motions and assignments. Added detail slide for presentable files. Updated list and detail slides for agenda items including slides for list of speakers.
This commit is contained in:
parent
34befe8f7b
commit
06ead753dc
@ -10,11 +10,39 @@ from .views import ItemViewSet
|
|||||||
|
|
||||||
class ItemListSlide(ProjectorElement):
|
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):
|
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(
|
yield ProjectorRequirement(
|
||||||
view_class=ItemViewSet,
|
view_class=ItemViewSet,
|
||||||
view_action='list')
|
view_action='list')
|
||||||
@ -24,13 +52,17 @@ class ItemDetailSlide(ProjectorElement):
|
|||||||
"""
|
"""
|
||||||
Slide definitions for Item model.
|
Slide definitions for Item model.
|
||||||
|
|
||||||
To activate this slide as list of speakers slide, set 'list_of_speakers'
|
This is only for detail slides. You have to set 'id'.
|
||||||
true.
|
|
||||||
|
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):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
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():
|
if not Item.objects.filter(pk=pk).exists():
|
||||||
raise ProjectorException(_('Item does not exist.'))
|
raise ProjectorException(_('Item does not exist.'))
|
||||||
return {'id': pk, 'list_of_speakers': self.config_entry.get('list_of_speakers', False)}
|
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):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
if pk is not None:
|
if pk is not None:
|
||||||
|
# Detail slide.
|
||||||
try:
|
try:
|
||||||
item = Item.objects.get(pk=pk)
|
item = Item.objects.get(pk=pk)
|
||||||
except Item.DoesNotExist:
|
except Item.DoesNotExist:
|
||||||
|
@ -8,21 +8,35 @@ from .models import Assignment
|
|||||||
from .views import AssignmentViewSet
|
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'
|
name = 'assignments/assignment'
|
||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
pk = self.config_entry.get('id')
|
||||||
if not Assignment.objects.filter(pk=pk).exists():
|
if pk is None:
|
||||||
raise ProjectorException(_('Assignment does not exist.'))
|
# List slide.
|
||||||
return {'id': pk}
|
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):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
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:
|
try:
|
||||||
assignment = Assignment.objects.get(pk=pk)
|
assignment = Assignment.objects.get(pk=pk)
|
||||||
except Assignment.DoesNotExist:
|
except Assignment.DoesNotExist:
|
||||||
|
@ -6,6 +6,10 @@ class MediafileAppConfig(AppConfig):
|
|||||||
verbose_name = 'OpenSlides Mediafiles'
|
verbose_name = 'OpenSlides Mediafiles'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
# Load projector elements.
|
||||||
|
# Do this by just importing all from these files.
|
||||||
|
from . import projector # noqa
|
||||||
|
|
||||||
# Import all required stuff.
|
# Import all required stuff.
|
||||||
from openslides.utils.rest_api import router
|
from openslides.utils.rest_api import router
|
||||||
from .views import MediafileViewSet
|
from .views import MediafileViewSet
|
||||||
|
32
openslides/mediafiles/projector.py
Normal file
32
openslides/mediafiles/projector.py
Normal 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))
|
@ -8,21 +8,35 @@ from .models import Motion
|
|||||||
from .views import CategoryViewSet, MotionViewSet, WorkflowViewSet
|
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'
|
name = 'motions/motion'
|
||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
pk = self.config_entry.get('id')
|
||||||
if not Motion.objects.filter(pk=pk).exists():
|
if pk is None:
|
||||||
raise ProjectorException(_('Motion does not exist.'))
|
# List slide.
|
||||||
return {'id': pk}
|
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):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
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:
|
try:
|
||||||
motion = Motion.objects.get(pk=pk)
|
motion = Motion.objects.get(pk=pk)
|
||||||
except Motion.DoesNotExist:
|
except Motion.DoesNotExist:
|
||||||
|
Loading…
Reference in New Issue
Block a user