Skip to content

Commit

Permalink
Order persons by surname #200
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaith committed Jan 13, 2015
1 parent 4565e40 commit 067b46c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions talks/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def __unicode__(self):
def get_absolute_url(self):
return reverse('show-person', args=[self.slug])

@property
def surname(self):
# Attempt to extract the surname as the last word of the name. This will be used for sorting on
return self.name.split(' ')[-1]

@property
def speaker_events(self):
events = Event.published.filter(personevent__role=ROLES_SPEAKER,
Expand Down
4 changes: 3 additions & 1 deletion talks/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ def contributors_eventgroups(request):
@login_required()
@permission_required('events.change_person', raise_exception=PermissionDenied)
def contributors_persons(request):
persons = Person.objects.all().order_by('name')
persons = Person.objects.all()
count = request.GET.get('count', 20)
page = request.GET.get('page', 1)

persons = sorted(persons, key=lambda person: person.surname)

paginator = Paginator(persons, count)

try:
Expand Down

0 comments on commit 067b46c

Please sign in to comment.