sort persons in motions
This commit is contained in:
parent
8014f327a2
commit
1dc7d45670
@ -162,8 +162,8 @@ class Motion(models.Model, SlideMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def supporters(self):
|
def supporters(self):
|
||||||
for object in self.motionsupporter_set.all():
|
return sorted([object.person for object in self.motionsupporter_set.all()],
|
||||||
yield object.person
|
key=lambda person: person.sort_name)
|
||||||
|
|
||||||
def is_supporter(self, person):
|
def is_supporter(self, person):
|
||||||
try:
|
try:
|
||||||
|
@ -86,8 +86,8 @@ class User(DjangoUser, PersonMixin, Person, SlideMixin):
|
|||||||
@property
|
@property
|
||||||
def sort_name(self):
|
def sort_name(self):
|
||||||
if config['participant_sort_users_by_first_name']:
|
if config['participant_sort_users_by_first_name']:
|
||||||
return self.first_name
|
return self.first_name.lower()
|
||||||
return self.last_name
|
return self.last_name.lower()
|
||||||
|
|
||||||
@models.permalink
|
@models.permalink
|
||||||
def get_absolute_url(self, link='view'):
|
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.
|
Return the part of the name, which is used for sorting.
|
||||||
For example the pre-name or the last-name
|
For example the pre-name or the last-name
|
||||||
"""
|
"""
|
||||||
return self.__repr__()
|
return self.clean_name.lower()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def clean_name(self):
|
def clean_name(self):
|
||||||
|
@ -22,7 +22,7 @@ class PersonChoices(object):
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
if self.field.empty_label is not None:
|
if self.field.empty_label is not None:
|
||||||
yield (u"", self.field.empty_label)
|
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)
|
yield (person.person_id, person)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user