sort persons in motions

This commit is contained in:
Oskar Hahn 2012-11-22 16:54:56 +01:00
parent 8014f327a2
commit 1dc7d45670
4 changed files with 6 additions and 6 deletions

View File

@ -162,8 +162,8 @@ class Motion(models.Model, SlideMixin):
@property
def supporters(self):
for object in self.motionsupporter_set.all():
yield object.person
return sorted([object.person for object in self.motionsupporter_set.all()],
key=lambda person: person.sort_name)
def is_supporter(self, person):
try:

View File

@ -86,8 +86,8 @@ class User(DjangoUser, PersonMixin, Person, SlideMixin):
@property
def sort_name(self):
if config['participant_sort_users_by_first_name']:
return self.first_name
return self.last_name
return self.first_name.lower()
return self.last_name.lower()
@models.permalink
def get_absolute_url(self, link='view'):

View File

@ -35,7 +35,7 @@ class Person(object):
Return the part of the name, which is used for sorting.
For example the pre-name or the last-name
"""
return self.__repr__()
return self.clean_name.lower()
@property
def clean_name(self):

View File

@ -22,7 +22,7 @@ class PersonChoices(object):
def __iter__(self):
if self.field.empty_label is not None:
yield (u"", self.field.empty_label)
for person in Persons():
for person in sorted(Persons(), key=lambda person: person.sort_name):
yield (person.person_id, person)