OpenSlides/openslides/users/projector.py
Norman Jäckel dc7d27a985 Added REST API for projector. Introduced new projector API.
Added custom slide projector element class.
Added welcome slide as custom slide.
Added user slide projector element class.
Added clock, countdown ans message projector elements.
Renamed SignalConnectMetaClass classmethod get_all_objects to get_all (private API).
Added migrations to core app.
Fixed and wrote tests.
Updated CHANGELOG.
2015-05-29 12:44:25 +02:00

30 lines
817 B
Python

from django.utils.translation import ugettext as _
from openslides.core.exceptions import ProjectorException
from openslides.utils.projector import ProjectorElement
from .models import User
class UserSlide(ProjectorElement):
"""
Slide definitions for user model.
"""
name = 'users/user'
scripts = 'users/user_slide.js'
def get_context(self):
pk = self.config_entry.get('id')
try:
user = User.objects.get(pk=pk)
except User.DoesNotExist:
raise ProjectorException(_('User does not exist.'))
result = [{
'collection': 'users/user',
'id': pk}]
for group in user.groups.all():
result.append({
'collection': 'users/group',
'id': group.pk})
return result