OpenSlides/openslides/motions/projector.py
Emanuel Schuetze c2920407bb Template improvements
- Activate slides for users, customslides, motions, assignments.
- Add delete confirm message.
- Fixed required form fields.
- Added version template.
- Improved user import. Updated csv files.
2015-06-25 00:15:56 +02:00

60 lines
2.3 KiB
Python

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))
if motion.category:
yield ProjectorRequirement(
view_class=CategoryViewSet,
view_action='retrieve',
pk=str(motion.category.pk))
yield ProjectorRequirement(
view_class=WorkflowViewSet,
view_action='retrieve',
pk=str(motion.workflow))
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))