comparison gpp/downloads/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 7e8d2dda99e3
children 41411066b16d
comparison
equal deleted inserted replaced
242:7e8d2dda99e3 243:7ddd60164245
82 82
83 ####################################################################### 83 #######################################################################
84 84
85 @login_required 85 @login_required
86 def new(request): 86 def new(request):
87 downloads = Download.public_objects.order_by('-date_added')[:DLS_PER_PAGE] 87 """Display new downloads with pagination."""
88
89 downloads = Download.public_objects.order_by('-date_added')
90
91 paginator = create_paginator(downloads)
92 page = get_page(request.GET)
93 try:
94 the_page = paginator.page(page)
95 except InvalidPage:
96 raise Http404
97
88 return render_to_response('downloads/download_summary.html', { 98 return render_to_response('downloads/download_summary.html', {
89 'downloads' : downloads, 99 'page': the_page,
90 'title' : 'Newest Downloads', 100 'title': 'Newest Downloads',
91 }, 101 },
92 context_instance = RequestContext(request)) 102 context_instance = RequestContext(request))
93 103
94 ####################################################################### 104 #######################################################################
95 105
96 @login_required 106 @login_required
97 def popular(request): 107 def popular(request):
98 downloads = Download.public_objects.order_by('-hits')[:DLS_PER_PAGE] 108 """Display popular downloads with pagination."""
109
110 downloads = Download.public_objects.order_by('-hits')
111
112 paginator = create_paginator(downloads)
113 page = get_page(request.GET)
114 try:
115 the_page = paginator.page(page)
116 except InvalidPage:
117 raise Http404
118
99 return render_to_response('downloads/download_summary.html', { 119 return render_to_response('downloads/download_summary.html', {
100 'downloads' : downloads, 120 'page': the_page,
101 'title' : 'Popular Downloads', 121 'title': 'Popular Downloads',
102 }, 122 },
103 context_instance = RequestContext(request)) 123 context_instance = RequestContext(request))
104 124
105 ####################################################################### 125 #######################################################################
106 126
107 @login_required 127 @login_required
108 def rating(request): 128 def rating(request):
109 downloads = Download.public_objects.order_by('-average_score')[:DLS_PER_PAGE] 129 """Display downloads by rating with pagination."""
130
131 downloads = Download.public_objects.order_by('-average_score')
132 paginator = create_paginator(downloads)
133 page = get_page(request.GET)
134 try:
135 the_page = paginator.page(page)
136 except InvalidPage:
137 raise Http404
138
110 return render_to_response('downloads/download_summary.html', { 139 return render_to_response('downloads/download_summary.html', {
111 'downloads' : downloads, 140 'page': the_page,
112 'title' : 'Highest Rated Downloads', 141 'title': 'Highest Rated Downloads',
113 }, 142 },
114 context_instance = RequestContext(request)) 143 context_instance = RequestContext(request))
115 144
116 ####################################################################### 145 #######################################################################
117 146