From 5cd223680e35e90bfc39ae22a4638204d0beaa98 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 27 Feb 2011 11:52:27 -0600 Subject: Slight refactor of user list views Signed-off-by: Dan McGee --- public/views.py | 36 ++++++++++++++++++++++++------------ urls.py | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/public/views.py b/public/views.py index 551e1e18..46291b88 100644 --- a/public/views.py +++ b/public/views.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import User from django.db.models import Q +from django.http import Http404 from django.views.generic import list_detail from django.views.generic.simple import direct_to_template @@ -17,23 +18,34 @@ def index(request): } return direct_to_template(request, 'public/index.html', context) -def userlist(request, type='Developers'): +USER_LISTS = { + 'devs': { + 'user_type': 'Developers', + 'description': "This is a list of the current Arch Linux Developers. They maintain the [core] and [extra] package repositories in addition to doing any other developer duties.", + }, + 'tus': { + 'user_type': 'Trusted Users', + 'description': "Here are all your friendly Arch Linux Trusted Users who are in charge of the [community] repository.", + }, + 'fellows': { + 'user_type': 'Fellows', + 'description': "Below you can find a list of ex-developers (aka project fellows). These folks helped make Arch what it is today. Thanks!", + }, +} + +def userlist(request, type='devs'): users = User.objects.order_by('username').select_related('userprofile') - if type == 'Developers': + if type == 'devs': users = users.filter(is_active=True, groups__name="Developers") - msg = "This is a list of the current Arch Linux Developers. They maintain the [core] and [extra] package repositories in addition to doing any other developer duties." - elif type == 'Trusted Users': + elif type == 'tus': users = users.filter(is_active=True, groups__name="Trusted Users") - msg = "Here are all your friendly Arch Linux Trusted Users who are in charge of the [community] repository." - elif type == 'Fellows': + elif type == 'fellows': users = users.filter(is_active=False, groups__name__in=["Developers", "Trusted Users"]) - msg = "Below you can find a list of ex-developers (aka project fellows). These folks helped make Arch what it is today. Thanks!" + else: + raise Http404 - context = { - 'user_type': type, - 'description': msg, - 'users': users, - } + context = USER_LISTS[type].copy() + context['users'] = users return direct_to_template(request, 'public/userlist.html', context) def donate(request): diff --git a/urls.py b/urls.py index da937666..3608da67 100644 --- a/urls.py +++ b/urls.py @@ -56,9 +56,9 @@ (r'^about/$', direct_to_template, {'template': 'public/about.html'}, 'page-about'), (r'^art/$', direct_to_template, {'template': 'public/art.html'}, 'page-art'), (r'^svn/$', direct_to_template, {'template': 'public/svn.html'}, 'page-svn'), - (r'^developers/$', 'userlist', { 'type':'Developers' }, 'page-devs'), - (r'^trustedusers/$', 'userlist', { 'type':'Trusted Users' }, 'page-tus'), - (r'^fellows/$', 'userlist', { 'type':'Fellows' }, 'page-fellows'), + (r'^developers/$', 'userlist', { 'type':'devs' }, 'page-devs'), + (r'^trustedusers/$', 'userlist', { 'type':'tus' }, 'page-tus'), + (r'^fellows/$', 'userlist', { 'type':'fellows' }, 'page-fellows'), (r'^donate/$', 'donate', {}, 'page-donate'), (r'^download/$', 'download', {}, 'page-download'), ) -- cgit v1.2.3-54-g00ecf