Fixed #814 Sorting of candidates in the assignment

This commit is contained in:
Oskar Hahn 2013-07-08 14:08:27 +02:00
parent f39e8dd92e
commit 47d70d5a73

View File

@ -13,6 +13,7 @@
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop
from django.utils.datastructures import SortedDict
from openslides.utils.person import PersonField from openslides.utils.person import PersonField
from openslides.config.api import config from openslides.config.api import config
@ -173,7 +174,7 @@ class Assignment(models.Model, SlideMixin):
returns a table represented as a list with all candidates from all returns a table represented as a list with all candidates from all
related polls and their vote results. related polls and their vote results.
""" """
vote_results_dict = {} vote_results_dict = SortedDict()
# All polls related to this assigment # All polls related to this assigment
polls = self.poll_set.all() polls = self.poll_set.all()
if only_published: if only_published:
@ -183,6 +184,8 @@ class Assignment(models.Model, SlideMixin):
for poll in polls: for poll in polls:
options += poll.get_options() options += poll.get_options()
options.sort(key=lambda option: option.candidate.sort_name)
for option in options: for option in options:
candidate = option.candidate candidate = option.candidate
if candidate in vote_results_dict: if candidate in vote_results_dict: