sort persons in motions
This commit is contained in:
parent
8014f327a2
commit
1dc7d45670
@ -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:
|
||||
|
@ -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'):
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user