sort persons
This commit is contained in:
parent
f40f091658
commit
fbf81e7780
@ -161,6 +161,7 @@ class Assignment(models.Model, SlideMixin):
|
||||
participants = []
|
||||
for candidate in candidates.all():
|
||||
participants.append(candidate.person)
|
||||
participants.sort(key=lambda person: person.sort_name)
|
||||
return participants
|
||||
#return candidates.values_list('person', flat=True)
|
||||
|
||||
@ -179,7 +180,6 @@ class Assignment(models.Model, SlideMixin):
|
||||
poll.set_options([{'candidate': person} for person in self.candidates])
|
||||
return poll
|
||||
|
||||
|
||||
def vote_results(self, only_published):
|
||||
"""
|
||||
returns a table represented as a list with all candidates from all
|
||||
|
@ -537,7 +537,7 @@ class AssignmentPollPDF(PDFView):
|
||||
stylesheet['Ballot_title']))
|
||||
cell.append(Paragraph(self.poll.assignment.polldescription,
|
||||
stylesheet['Ballot_subtitle']))
|
||||
options = self.poll.get_options().order_by('candidate')
|
||||
options = self.poll.get_options()
|
||||
|
||||
ballot_string = _("%d. ballot") % self.poll.get_ballot()
|
||||
candidate_string = ungettext("%d candidate", "%d candidates",
|
||||
|
@ -83,6 +83,12 @@ class User(DjangoUser, PersonMixin, Person, SlideMixin):
|
||||
self.set_password(password)
|
||||
self.save()
|
||||
|
||||
@property
|
||||
def sort_name(self):
|
||||
if config['participant_sort_users_by_first_name']:
|
||||
return self.first_name
|
||||
return self.last_name
|
||||
|
||||
@models.permalink
|
||||
def get_absolute_url(self, link='view'):
|
||||
"""
|
||||
|
@ -29,6 +29,14 @@ class Person(object):
|
||||
"""
|
||||
return str(self.person_id)
|
||||
|
||||
@property
|
||||
def sort_name(self):
|
||||
"""
|
||||
Return the part of the name, which is used for sorting.
|
||||
For example the pre-name or the last-name
|
||||
"""
|
||||
return self.__repr__()
|
||||
|
||||
@property
|
||||
def clean_name(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user