Mercurial > public > sg101
comparison gpp/shoutbox/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 | e1d1a70d312d |
children |
comparison
equal
deleted
inserted
replaced
242:7e8d2dda99e3 | 243:7ddd60164245 |
---|---|
14 from django.contrib.auth.decorators import login_required | 14 from django.contrib.auth.decorators import login_required |
15 from django.views.decorators.http import require_POST | 15 from django.views.decorators.http import require_POST |
16 | 16 |
17 from core.paginator import DiggPaginator | 17 from core.paginator import DiggPaginator |
18 from core.functions import email_admins | 18 from core.functions import email_admins |
19 from core.functions import get_page | |
19 from shoutbox.forms import ShoutBoxForm | 20 from shoutbox.forms import ShoutBoxForm |
20 from shoutbox.models import Shout | 21 from shoutbox.models import Shout |
21 from shoutbox.models import ShoutFlag | 22 from shoutbox.models import ShoutFlag |
22 | 23 |
23 SHOUTS_PER_PAGE = 10 | 24 SHOUTS_PER_PAGE = 10 |
49 'shout': shout, | 50 'shout': shout, |
50 }, | 51 }, |
51 context_instance = RequestContext(request)) | 52 context_instance = RequestContext(request)) |
52 | 53 |
53 | 54 |
54 def view_history(request, page=1): | 55 def view_history(request): |
55 """This view allows one to view the shoutbox history.""" | 56 """This view allows one to view the shoutbox history.""" |
56 paginator = DiggPaginator(Shout.objects.all().select_related(), | 57 paginator = DiggPaginator(Shout.objects.all().select_related(), |
57 SHOUTS_PER_PAGE, body=5, tail=3, margin=3, padding=2) | 58 SHOUTS_PER_PAGE, body=5, tail=3, margin=3, padding=2) |
59 page = get_page(request.GET) | |
58 try: | 60 try: |
59 the_page = paginator.page(int(page)) | 61 the_page = paginator.page(page) |
60 except InvalidPage: | 62 except InvalidPage: |
61 raise Http404 | 63 raise Http404 |
62 | 64 |
63 return render_to_response('shoutbox/view.html', { | 65 return render_to_response('shoutbox/view.html', { |
64 'page': the_page, | 66 'page': the_page, |