adds routing.py and view.py changes
authorcfdv <caldavis@gmail.com>
Tue, 7 Jun 2011 05:25:08 +0000 (00:25 -0500)
committercfdv <caldavis@gmail.com>
Thu, 16 Jun 2011 17:59:48 +0000 (12:59 -0500)
mediagoblin/user_pages/routing.py
mediagoblin/user_pages/views.py

index c5e9a984b16b846d75004026525cb3e657d6e1e7..929987268205667486cf0e909854e25480a0e2a6 100644 (file)
@@ -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"),
index 323c3e548dab3ed17fef16cb18a56db985235485..ceea5158367b5d21f8b78940db650f825d77e0b6 100644 (file)
@@ -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):