Updated server logic for assignment detail and poll slide. Fixed #2422.
This commit is contained in:
parent
e340d83777
commit
495ddb7d2d
@ -1,17 +1,28 @@
|
|||||||
from ..core.exceptions import ProjectorException
|
from ..core.exceptions import ProjectorException
|
||||||
from ..utils.projector import ProjectorElement
|
from ..utils.projector import ProjectorElement
|
||||||
from .models import Assignment
|
from .models import Assignment, AssignmentPoll
|
||||||
|
|
||||||
|
|
||||||
class AssignmentSlide(ProjectorElement):
|
class AssignmentSlide(ProjectorElement):
|
||||||
"""
|
"""
|
||||||
Slide definitions for Assignment model.
|
Slide definitions for Assignment model.
|
||||||
|
|
||||||
|
You can send a poll id to get a poll slide.
|
||||||
"""
|
"""
|
||||||
name = 'assignments/assignment'
|
name = 'assignments/assignment'
|
||||||
|
|
||||||
def check_data(self):
|
def check_data(self):
|
||||||
if not Assignment.objects.filter(pk=self.config_entry.get('id')).exists():
|
if not Assignment.objects.filter(pk=self.config_entry.get('id')).exists():
|
||||||
raise ProjectorException('Election does not exist.')
|
raise ProjectorException('Election does not exist.')
|
||||||
|
poll_id = self.config_entry.get('poll')
|
||||||
|
if poll_id:
|
||||||
|
# Poll slide.
|
||||||
|
try:
|
||||||
|
poll = AssignmentPoll.objects.get(pk=poll_id)
|
||||||
|
except AssignmentPoll.DoesNotExist:
|
||||||
|
raise ProjectorException('Poll does not exist.')
|
||||||
|
if poll.assignment_id != self.config_entry.get('id'):
|
||||||
|
raise ProjectorException('Assignment id and poll do not belong together.')
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
try:
|
try:
|
||||||
@ -22,15 +33,18 @@ class AssignmentSlide(ProjectorElement):
|
|||||||
else:
|
else:
|
||||||
yield assignment
|
yield assignment
|
||||||
yield assignment.agenda_item
|
yield assignment.agenda_item
|
||||||
for user in assignment.related_users.all():
|
if not config_entry.get('poll'):
|
||||||
# Yield user instances of current candidates (i. e. future
|
# Assignment detail slide. Yield user instances of current
|
||||||
# poll participants) and elected persons (i. e. former poll
|
# candidates (i. e. future poll participants) and elected
|
||||||
# participants).
|
# persons (i. e. former poll participants).
|
||||||
yield user
|
for user in assignment.related_users.all():
|
||||||
for poll in assignment.polls.all().prefetch_related('options'):
|
yield user
|
||||||
# Yield user instances of the participants of all polls.
|
else:
|
||||||
for option in poll.options.all():
|
# Assignment poll slide. Yield user instances of the
|
||||||
yield option.candidate
|
# participants of all polls.
|
||||||
|
for poll in assignment.polls.all().prefetch_related('options'):
|
||||||
|
for option in poll.options.all():
|
||||||
|
yield option.candidate
|
||||||
|
|
||||||
def need_full_update_for_this(self, collection_element):
|
def need_full_update_for_this(self, collection_element):
|
||||||
# Full update if assignment changes because then we may have new
|
# Full update if assignment changes because then we may have new
|
||||||
|
Loading…
Reference in New Issue
Block a user