comparison gpp/bio/views.py @ 243:7ddd60164245

For #93: remove the page number from the URL. This commit fixes the shoutbox and member list. It also contains a change to downloads to add pagination to the new, popular, and highest rated views.
author Brian Neal <bgneal@gmail.com>
date Thu, 16 Sep 2010 01:06:43 +0000
parents b4305e18d3af
children 75ea1a8be7f2
comparison
equal deleted inserted replaced
242:7e8d2dda99e3 243:7ddd60164245
8 from django.contrib import auth 8 from django.contrib import auth
9 from django.contrib import messages 9 from django.contrib import messages
10 from django.http import HttpResponse 10 from django.http import HttpResponse
11 from django.http import HttpResponseBadRequest 11 from django.http import HttpResponseBadRequest
12 from django.http import HttpResponseRedirect 12 from django.http import HttpResponseRedirect
13 from django.http import Http404
13 from django.core.paginator import InvalidPage 14 from django.core.paginator import InvalidPage
14 from django.core.urlresolvers import reverse 15 from django.core.urlresolvers import reverse
15 from django.contrib.auth.decorators import login_required 16 from django.contrib.auth.decorators import login_required
16 from django.views.decorators.http import require_POST 17 from django.views.decorators.http import require_POST
17 18
26 from bio.forms import EditUserForm 27 from bio.forms import EditUserForm
27 from bio.forms import EditUserProfileForm 28 from bio.forms import EditUserProfileForm
28 from bio.forms import SearchUsersForm 29 from bio.forms import SearchUsersForm
29 from core.paginator import DiggPaginator 30 from core.paginator import DiggPaginator
30 from core.functions import email_admins 31 from core.functions import email_admins
31 32 from core.functions import get_page
32 ####################################################################### 33
33 34 #######################################################################
34 @login_required 35
35 def member_list(request, type='user', page=1): 36 @login_required
37 def member_list(request, type='user'):
36 """ 38 """
37 This view displays the member list. Only active members are displayed. 39 This view displays the member list. Only active members are displayed.
38 """ 40 """
39 qs = auth.models.User.objects.filter(is_active=True) 41 qs = auth.models.User.objects.filter(is_active=True)
40 if type == 'user': 42 if type == 'user':
42 else: 44 else:
43 qs = qs.order_by('date_joined') 45 qs = qs.order_by('date_joined')
44 num_members = qs.count() 46 num_members = qs.count()
45 47
46 paginator = DiggPaginator(qs, 20, body=5, tail=3, margin=3, padding=2) 48 paginator = DiggPaginator(qs, 20, body=5, tail=3, margin=3, padding=2)
49 page = get_page(request.GET)
47 try: 50 try:
48 the_page = paginator.page(int(page)) 51 the_page = paginator.page(page)
49 except InvalidPage: 52 except InvalidPage:
50 raise Http404 53 raise Http404
51 54
52 # Attach user profiles to each post to avoid using get_user_profile() in 55 # Attach user profiles to each post to avoid using get_user_profile() in
53 # the template. 56 # the template.