2015-02-18 01:45:39 +01:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
|
|
from openslides.core.exceptions import ProjectorException
|
2015-06-12 21:08:57 +02:00
|
|
|
from openslides.utils.projector import ProjectorElement, ProjectorRequirement
|
2015-02-18 01:45:39 +01:00
|
|
|
|
|
|
|
from .models import User
|
2015-06-12 21:08:57 +02:00
|
|
|
from .views import GroupViewSet, UserViewSet
|
2015-02-18 01:45:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
class UserSlide(ProjectorElement):
|
|
|
|
"""
|
|
|
|
Slide definitions for user model.
|
|
|
|
"""
|
|
|
|
name = 'users/user'
|
|
|
|
|
|
|
|
def get_context(self):
|
|
|
|
pk = self.config_entry.get('id')
|
2015-06-17 09:45:00 +02:00
|
|
|
if not User.objects.filter(pk=pk).exists():
|
2015-02-18 01:45:39 +01:00
|
|
|
raise ProjectorException(_('User does not exist.'))
|
2015-06-17 09:45:00 +02:00
|
|
|
return {'id': pk}
|
2015-06-12 21:08:57 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2015-06-17 09:45:00 +02:00
|
|
|
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():
|
2015-06-12 21:08:57 +02:00
|
|
|
yield ProjectorRequirement(
|
2015-06-17 09:45:00 +02:00
|
|
|
view_class=GroupViewSet,
|
2015-06-12 21:08:57 +02:00
|
|
|
view_action='retrieve',
|
2015-06-17 09:45:00 +02:00
|
|
|
pk=str(group.pk))
|