From 47d70d5a737797b23976c9d59766c04a6102e3da Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 8 Jul 2013 14:08:27 +0200 Subject: [PATCH] Fixed #814 Sorting of candidates in the assignment --- openslides/assignment/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 85491b9a2..e4f6fa570 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -13,6 +13,7 @@ from django.core.urlresolvers import reverse from django.db import models 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.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 related polls and their vote results. """ - vote_results_dict = {} + vote_results_dict = SortedDict() # All polls related to this assigment polls = self.poll_set.all() if only_published: @@ -183,6 +184,8 @@ class Assignment(models.Model, SlideMixin): for poll in polls: options += poll.get_options() + options.sort(key=lambda option: option.candidate.sort_name) + for option in options: candidate = option.candidate if candidate in vote_results_dict: