2016-09-17 22:26:23 +02:00
|
|
|
from ..core.exceptions import ProjectorException
|
|
|
|
from ..utils.projector import ProjectorElement
|
|
|
|
from .models import Assignment
|
2015-06-24 22:11:54 +02:00
|
|
|
|
|
|
|
|
2015-06-25 20:36:46 +02:00
|
|
|
class AssignmentSlide(ProjectorElement):
|
2015-06-24 22:11:54 +02:00
|
|
|
"""
|
2015-06-25 20:36:46 +02:00
|
|
|
Slide definitions for Assignment model.
|
2015-06-24 22:11:54 +02:00
|
|
|
"""
|
|
|
|
name = 'assignments/assignment'
|
|
|
|
|
2016-02-27 20:25:06 +01:00
|
|
|
def check_data(self):
|
2016-09-17 22:26:23 +02:00
|
|
|
if not Assignment.objects.filter(pk=self.config_entry.get('id')).exists():
|
|
|
|
raise ProjectorException('Election does not exist.')
|
2015-06-24 22:11:54 +02:00
|
|
|
|
|
|
|
def get_requirements(self, config_entry):
|
2016-09-17 22:26:23 +02:00
|
|
|
try:
|
|
|
|
assignment = Assignment.objects.get(pk=config_entry.get('id'))
|
|
|
|
except Assignment.DoesNotExist:
|
|
|
|
# Assignment does not exist. Just do nothing.
|
|
|
|
pass
|
2015-06-25 20:36:46 +02:00
|
|
|
else:
|
2016-09-17 22:26:23 +02:00
|
|
|
yield assignment
|
|
|
|
yield assignment.agenda_item
|
|
|
|
for user in assignment.related_users.all():
|
|
|
|
yield user
|
|
|
|
for poll in assignment.polls.all().prefetch_related('options'):
|
|
|
|
for option in poll.options.all():
|
|
|
|
yield option.candidate
|