OpenSlides/openslides/users/projector.py
Oskar Hahn a4c00d5ee3 Angular Client
* Split angular app into a site- and a projector app
* Created client slide api and slides for customslide and user
* JS-function to activate a slide
2015-06-18 23:23:34 +02:00

35 lines
1.0 KiB
Python

from django.utils.translation import ugettext as _
from openslides.core.exceptions import ProjectorException
from openslides.utils.projector import ProjectorElement, ProjectorRequirement
from .models import User
from .views import GroupViewSet, UserViewSet
class UserSlide(ProjectorElement):
"""
Slide definitions for user model.
"""
name = 'users/user'
def get_context(self):
pk = self.config_entry.get('id')
if not User.objects.filter(pk=pk).exists():
raise ProjectorException(_('User does not exist.'))
return {'id': pk}
def get_requirements(self, config_entry):
pk = config_entry.get('id')
if pk is not None:
yield ProjectorRequirement(
view_class=UserViewSet,
view_action='retrive',
pk=pk)
for group in User.objects.get(pk=pk).groups.all():
yield ProjectorRequirement(
view_class=GroupViewSet,
view_action='retrieve',
pk=str(group.pk))