# HG changeset patch # User Brian Neal # Date 1284599203 0 # Node ID 7ddd60164245e7140dd695be1caaefb4ffa2ecb8 # Parent 7e8d2dda99e38cce86bdccb78ae783bd5250ebe5 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. diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/bio/urls.py --- a/gpp/bio/urls.py Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/bio/urls.py Thu Sep 16 01:06:43 2010 +0000 @@ -2,9 +2,9 @@ from django.conf.urls.defaults import * urlpatterns = patterns('bio.views', - url(r'^members/(?Puser|date)/page/(?P\d+)/$', + url(r'^members/(?Puser|date)/$', 'member_list', - name='bio-members_full'), + name='bio-member_list'), url(r'^members/search/$', 'member_search', name='bio-member_search'), url(r'^me/$', 'my_profile', name='bio-me'), url(r'^view/(?P\w{1,30})/$', 'view_profile', name='bio-view_profile'), @@ -13,11 +13,3 @@ url(r'^avatar/$', 'change_avatar', name='bio-change_avatar'), url(r'^flag/(\d+)/$', 'flag_profile', name='bio-flag_profile'), ) - -urlpatterns += patterns('django.views.generic.simple', - url(r'^members/$', - 'redirect_to', - {'url': '/profile/members/user/page/1/'}, - name='bio-members'), -) - diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/bio/views.py --- a/gpp/bio/views.py Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/bio/views.py Thu Sep 16 01:06:43 2010 +0000 @@ -10,6 +10,7 @@ from django.http import HttpResponse from django.http import HttpResponseBadRequest from django.http import HttpResponseRedirect +from django.http import Http404 from django.core.paginator import InvalidPage from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required @@ -28,11 +29,12 @@ from bio.forms import SearchUsersForm from core.paginator import DiggPaginator from core.functions import email_admins +from core.functions import get_page ####################################################################### @login_required -def member_list(request, type='user', page=1): +def member_list(request, type='user'): """ This view displays the member list. Only active members are displayed. """ @@ -44,8 +46,9 @@ num_members = qs.count() paginator = DiggPaginator(qs, 20, body=5, tail=3, margin=3, padding=2) + page = get_page(request.GET) try: - the_page = paginator.page(int(page)) + the_page = paginator.page(page) except InvalidPage: raise Http404 diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/downloads/views.py --- a/gpp/downloads/views.py Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/downloads/views.py Thu Sep 16 01:06:43 2010 +0000 @@ -84,10 +84,20 @@ @login_required def new(request): - downloads = Download.public_objects.order_by('-date_added')[:DLS_PER_PAGE] + """Display new downloads with pagination.""" + + downloads = Download.public_objects.order_by('-date_added') + + paginator = create_paginator(downloads) + page = get_page(request.GET) + try: + the_page = paginator.page(page) + except InvalidPage: + raise Http404 + return render_to_response('downloads/download_summary.html', { - 'downloads' : downloads, - 'title' : 'Newest Downloads', + 'page': the_page, + 'title': 'Newest Downloads', }, context_instance = RequestContext(request)) @@ -95,10 +105,20 @@ @login_required def popular(request): - downloads = Download.public_objects.order_by('-hits')[:DLS_PER_PAGE] + """Display popular downloads with pagination.""" + + downloads = Download.public_objects.order_by('-hits') + + paginator = create_paginator(downloads) + page = get_page(request.GET) + try: + the_page = paginator.page(page) + except InvalidPage: + raise Http404 + return render_to_response('downloads/download_summary.html', { - 'downloads' : downloads, - 'title' : 'Popular Downloads', + 'page': the_page, + 'title': 'Popular Downloads', }, context_instance = RequestContext(request)) @@ -106,10 +126,19 @@ @login_required def rating(request): - downloads = Download.public_objects.order_by('-average_score')[:DLS_PER_PAGE] + """Display downloads by rating with pagination.""" + + downloads = Download.public_objects.order_by('-average_score') + paginator = create_paginator(downloads) + page = get_page(request.GET) + try: + the_page = paginator.page(page) + except InvalidPage: + raise Http404 + return render_to_response('downloads/download_summary.html', { - 'downloads' : downloads, - 'title' : 'Highest Rated Downloads', + 'page': the_page, + 'title': 'Highest Rated Downloads', }, context_instance = RequestContext(request)) diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/shoutbox/urls.py --- a/gpp/shoutbox/urls.py Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/shoutbox/urls.py Thu Sep 16 01:06:43 2010 +0000 @@ -11,7 +11,5 @@ url(r'^shout/$', 'shout', name='shoutbox-shout'), url(r'^text/$', 'text', name='shoutbox-text'), url(r'^view/(\d+)/$', 'view_shout', name='shoutbox-view'), - url(r'^view/history/(?P\d+)/$', 'view_history', name='shoutbox-history'), + url(r'^view/history/$', 'view_history', name='shoutbox-history'), ) - -# vim: ts=4 sw=4 diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/shoutbox/views.py --- a/gpp/shoutbox/views.py Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/shoutbox/views.py Thu Sep 16 01:06:43 2010 +0000 @@ -16,6 +16,7 @@ from core.paginator import DiggPaginator from core.functions import email_admins +from core.functions import get_page from shoutbox.forms import ShoutBoxForm from shoutbox.models import Shout from shoutbox.models import ShoutFlag @@ -51,12 +52,13 @@ context_instance = RequestContext(request)) -def view_history(request, page=1): +def view_history(request): """This view allows one to view the shoutbox history.""" paginator = DiggPaginator(Shout.objects.all().select_related(), SHOUTS_PER_PAGE, body=5, tail=3, margin=3, padding=2) + page = get_page(request.GET) try: - the_page = paginator.page(int(page)) + the_page = paginator.page(page) except InvalidPage: raise Http404 diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/templates/base.html --- a/gpp/templates/base.html Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/templates/base.html Thu Sep 16 01:06:43 2010 +0000 @@ -59,7 +59,7 @@
  • Donations
  • Forums
  • IRC
  • -
  • Member List
  • +
  • Member List
  • Member Map
  • Private Messages
  • Podcast
  • diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/templates/bio/members.html --- a/gpp/templates/bio/members.html Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/templates/bio/members.html Thu Sep 16 01:06:43 2010 +0000 @@ -14,9 +14,9 @@

    {% if page.object_list %} diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/templates/downloads/download_summary.html --- a/gpp/templates/downloads/download_summary.html Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/templates/downloads/download_summary.html Thu Sep 16 01:06:43 2010 +0000 @@ -3,6 +3,8 @@ {% block title %}{{ title }}{% endblock %} {% block custom_css %} + + {% endblock %} {% block custom_js %} @@ -12,12 +14,14 @@ {% include 'downloads/navigation.html' %}

    {{ title }}

    -{% if downloads %} +{% if page.object_list %} +{% include 'core/pagination.html' %}
    -{% for download in downloads %} +{% for download in page.object_list %} {% include 'downloads/download.html' %} {% endfor %}
    +{% include 'core/pagination.html' %} {% else %}

    No downloads available at this time.

    {% endif %} diff -r 7e8d2dda99e3 -r 7ddd60164245 gpp/templates/shoutbox/shoutbox.html --- a/gpp/templates/shoutbox/shoutbox.html Wed Sep 15 03:24:01 2010 +0000 +++ b/gpp/templates/shoutbox/shoutbox.html Thu Sep 16 01:06:43 2010 +0000 @@ -10,7 +10,7 @@

    {% endfor %} -
    Shout History
    +
    Shout History
    {% if user.is_authenticated %}