2015-06-24 22:11:54 +02:00
|
|
|
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 Motion
|
|
|
|
from .views import CategoryViewSet, MotionViewSet, WorkflowViewSet
|
|
|
|
|
|
|
|
|
|
|
|
class MotionDetailSlide(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Slide definitions for motion model.
|
|
|
|
"""
|
|
|
|
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}
|
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
|
|
|
pk = config_entry.get('id')
|
|
|
|
if pk is not None:
|
|
|
|
try:
|
|
|
|
motion = Motion.objects.get(pk=pk)
|
|
|
|
except Motion.DoesNotExist:
|
|
|
|
# Motion does not exist. Just do nothing.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=MotionViewSet,
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(motion.pk))
|
2015-06-24 15:04:40 +02:00
|
|
|
if motion.category:
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=CategoryViewSet,
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(motion.category.pk))
|
2015-06-24 22:11:54 +02:00
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=WorkflowViewSet,
|
|
|
|
view_action='retrieve',
|
2015-06-24 15:04:40 +02:00
|
|
|
pk=str(motion.workflow))
|
2015-06-24 22:11:54 +02:00
|
|
|
for submitter in motion.submitters.all():
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=submitter.get_view_class(),
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(submitter.pk))
|
|
|
|
for supporter in motion.supporters.all():
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=supporter.get_view_class(),
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(supporter.pk))
|
|
|
|
for tag in motion.tags.all():
|
|
|
|
yield ProjectorRequirement(
|
|
|
|
view_class=TagViewSet,
|
|
|
|
view_action='retrieve',
|
|
|
|
pk=str(tag.pk))
|