From 9a522f383589de78cd278742ff2cfe3d655a24f8 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Tue, 30 Oct 2012 23:00:24 +0100 Subject: [PATCH] Use participant_sort_users_by_first_name config var for overview table, participant list (pdf) and first time passwords (pdf). --- openslides/participant/models.py | 2 +- openslides/participant/views.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openslides/participant/models.py b/openslides/participant/models.py index 4c356de36..851be38d0 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -145,7 +145,7 @@ class UsersAndGroupsToPersons(object): if config['participant_sort_users_by_first_name']: self.users = User.objects.all().order_by('first_name') else: - self.users = User.objects.all() + self.users = User.objects.all().order_by('last_name') self.groups = Group.objects.filter(group_as_person=True) def __iter__(self): diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 00599c327..99665a469 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -98,6 +98,8 @@ class Overview(ListView): else: if config['participant_sort_users_by_first_name']: query = query.order_by('first_name') + else: + query = query.order_by('last_name') if 'reverse' in sortfilter: query = query.reverse() @@ -215,7 +217,10 @@ class ParticipantsListPDF(PDFView): def append_to_pdf(self, story): data = [['#', _('Last Name'), _('First Name'), _('Group'), _('Type'), _('Committee')]] - sort = 'last_name' + if config['participant_sort_users_by_first_name']: + sort = 'first_name' + else: + sort = 'last_name' counter = 0 for user in User.objects.all().order_by(sort): counter += 1 @@ -257,7 +262,11 @@ class ParticipantsPasswordsPDF(PDFView): data = [] participant_pdf_system_url = config["participant_pdf_system_url"] participant_pdf_welcometext = config["participant_pdf_welcometext"] - for user in User.objects.all().order_by('last_name'): + if config['participant_sort_users_by_first_name']: + sort = 'first_name' + else: + sort = 'last_name' + for user in User.objects.all().order_by(sort): cell = [] cell.append(Spacer(0, 0.8 * cm)) cell.append(Paragraph(_("Account for OpenSlides"),