From 184f2240cb9384bac9e3319f2d184e405e364611 Mon Sep 17 00:00:00 2001 From: cfdv Date: Tue, 7 Jun 2011 00:25:08 -0500 Subject: [PATCH] adds routing.py and view.py changes --- mediagoblin/user_pages/routing.py | 2 ++ mediagoblin/user_pages/views.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index c5e9a984..92998726 100644 --- a/mediagoblin/user_pages/routing.py +++ b/mediagoblin/user_pages/routing.py @@ -19,6 +19,8 @@ from routes.route import Route user_routes = [ Route('mediagoblin.user_pages.user_home', "/{user}/", controller="mediagoblin.user_pages.views:user_home"), + Route('mediagoblin.user_pages.user_gallery', "/{user}/gallery/", + controller="mediagoblin.user_pages.views:user_gallery"), Route('mediagoblin.user_pages.media_home', '/{user}/m/{media}/', requirements=dict(m_id="[0-9a-fA-F]{24}"), controller="mediagoblin.user_pages.views:media_home"), diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 323c3e54..ceea5158 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -49,6 +49,36 @@ def user_home(request, page): 'media_entries': media_entries, 'pagination': pagination}) +@uses_pagination +def user_gallery(request, page): + """'Gallery' of a User()""" + user = request.db.User.find_one({ + 'username': request.matchdict['user'], + 'status': 'active'}) + if not user: + return exc.HTTPNotFound() + + cursor = request.db.MediaEntry.find( + {'uploader': user['_id'], + 'state': 'processed'}).sort('created', DESCENDING) + + pagination = Pagination(page, cursor) + media_entries = pagination() + + #if no data is available, return NotFound + if media_entries == None: + return exc.HTTPNotFound() + + template = request.template_env.get_template( + 'mediagoblin/user_pages/gallery.html') + + return Response( + template.render( + {'request': request, + 'user': user, + 'media_entries': media_entries, + 'pagination': pagination})) + @get_user_media_entry def media_home(request, media): -- 2.25.1