Enhence use of config var and Meta Class for default sorting of users

This commit is contained in:
Norman Jäckel 2012-09-14 03:02:00 +02:00
parent e5c132e34c
commit 269b093b28
2 changed files with 9 additions and 4 deletions

View File

@ -100,6 +100,7 @@ class User(DjangoUser, PersonMixin):
('can_manage_participant',
ugettext_noop("Can manage participant")),
)
ordering = ('last_name',)
class Group(DjangoGroup, PersonMixin):
@ -126,6 +127,9 @@ class Group(DjangoGroup, PersonMixin):
def __unicode__(self):
return unicode(self.name)
class Meta:
ordering = ('name',)
class UsersAndGroupsToPersons(object):
"""
@ -138,8 +142,8 @@ 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().order_by('last_name')
self.groups = Group.objects.filter(group_as_person=True).order_by('name')
self.users = User.objects.all()
self.groups = Group.objects.filter(group_as_person=True)
def __iter__(self):
if (not self.person_prefix_filter or

View File

@ -53,7 +53,7 @@ from openslides.participant.models import User, Group
class Overview(ListView):
"""
Show all participants.
Show all participants (users).
"""
permission_required = 'participant.can_see_participant'
template_name = 'participant/overview.html'
@ -96,7 +96,8 @@ class Overview(ListView):
query = query.order_by(
'%s' % sortfilter['sort'][0])
else:
query = query.order_by('last_name')
if config['participant_sort_users_by_first_name']:
query = query.order_by('first_name')
if 'reverse' in sortfilter:
query = query.reverse()