Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Fixes sorting of people
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Sommerhalder committed Apr 6, 2019
1 parent 77246ce commit 7bd6e1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
---------

- Fixes sorting of people.
[msom]

1.10.1 (2019-04-04)
~~~~~~~~~~~~~~~~~~~~

Expand Down
9 changes: 9 additions & 0 deletions onegov/agency/views/people.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections import namedtuple
from collections import OrderedDict
from itertools import groupby
from morepath import redirect
from onegov.agency import _
from onegov.agency import AgencyApp
Expand All @@ -11,6 +13,7 @@
from onegov.org.elements import Link
from onegov.org.forms import PersonForm
from onegov.org.models import AtoZ
from unidecode import unidecode


def get_person_form_class(model, request):
Expand Down Expand Up @@ -71,6 +74,12 @@ def get_title(self, item):
def get_items(self):
return people

def get_items_by_letter(self):
items_by_letter = OrderedDict()
for letter, items in groupby(self.get_items(), self.sortkey):
items_by_letter[unidecode(letter)] = tuple(items)
return items_by_letter

people = AtoZPeople(request).get_items_by_letter()

return {
Expand Down

0 comments on commit 7bd6e1c

Please sign in to comment.