Reorganizing the uses_pagination decorator a little and having it pass
in the page number to the view
This commit is contained in:
parent
af4d0b5cb0
commit
1301a8ad57
@ -52,14 +52,12 @@ def uses_pagination(controller):
|
||||
"""
|
||||
def wrapper(request, *args, **kwargs):
|
||||
try:
|
||||
page = int(request.str_GET['page'])
|
||||
page = int(request.GET.get('page', 1))
|
||||
if page < 0:
|
||||
return exc.HTTPNotFound()
|
||||
except ValueError:
|
||||
return exc.HTTPNotFound()
|
||||
except KeyError:
|
||||
request.str_GET['page'] = 1
|
||||
|
||||
return controller(request, *args, **kwargs)
|
||||
return controller(request, page, *args, **kwargs)
|
||||
|
||||
return _make_safe(wrapper,controller)
|
||||
|
@ -20,8 +20,9 @@ from mediagoblin.util import Pagination
|
||||
|
||||
from mediagoblin.decorators import uses_pagination
|
||||
|
||||
|
||||
@uses_pagination
|
||||
def user_home(request):
|
||||
def user_home(request, page):
|
||||
"""'Homepage' of a User()"""
|
||||
user = request.db.User.find_one({
|
||||
'username': request.matchdict['user'],
|
||||
@ -32,9 +33,8 @@ def user_home(request):
|
||||
cursor = request.db.MediaEntry \
|
||||
.find({'uploader': user, 'state': 'processed'}) \
|
||||
.sort('created', DESCENDING)
|
||||
|
||||
|
||||
pagination = Pagination( int(request.str_GET['page']), cursor)
|
||||
pagination = Pagination(page, cursor)
|
||||
media_entries = pagination()
|
||||
|
||||
#if no data is available, return NotFound
|
||||
|
Loading…
x
Reference in New Issue
Block a user