aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/user_pages
diff options
context:
space:
mode:
authorStefano Zacchiroli <zack@upsilon.cc>2012-12-18 12:34:30 +0100
committerStefano Zacchiroli <zack@upsilon.cc>2013-01-15 21:40:05 +0100
commitb0cc1ade404417a3b4c005ac4e11d5f71ac0c988 (patch)
treeb559ae4a13be5ae7226def7b23152fd5a1ca3487 /mediagoblin/user_pages
parentcf764377df3c985a3f036f14562f8a8a3ed8735f (diff)
downloadmediagoblin-b0cc1ade404417a3b4c005ac4e11d5f71ac0c988.tar.lz
mediagoblin-b0cc1ade404417a3b4c005ac4e11d5f71ac0c988.tar.xz
mediagoblin-b0cc1ade404417a3b4c005ac4e11d5f71ac0c988.zip
collections: add support to browse existing collections
- add a route at /u/<user>/collections/ (note trailing 's') that lists all existing collections - move there the "Create new collection" link, if the user is logged in - add a new link "Browse collections" from root.html
Diffstat (limited to 'mediagoblin/user_pages')
-rw-r--r--mediagoblin/user_pages/routing.py4
-rw-r--r--mediagoblin/user_pages/views.py17
2 files changed, 21 insertions, 0 deletions
diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py
index 63bf5c2a..50243a2b 100644
--- a/mediagoblin/user_pages/routing.py
+++ b/mediagoblin/user_pages/routing.py
@@ -48,6 +48,10 @@ add_route('mediagoblin.user_pages.media_collect',
'/u/<string:user>/m/<string:media>/collect/',
'mediagoblin.user_pages.views:media_collect')
+add_route('mediagoblin.user_pages.user_collections',
+ '/u/<string:user>/collections/',
+ 'mediagoblin.user_pages.views:user_collections')
+
add_route('mediagoblin.user_pages.user_collection',
'/u/<string:user>/collection/<string:collection>/',
'mediagoblin.user_pages.views:user_collection')
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index f115c3b8..6ff07818 100644
--- a/mediagoblin/user_pages/views.py
+++ b/mediagoblin/user_pages/views.py
@@ -337,6 +337,23 @@ def user_collection(request, page, url_user=None):
'pagination': pagination})
+@active_user_from_url
+@uses_pagination
+def user_collections(request, page, url_user=None):
+ """A User-defined Collection"""
+ collections = Collection.query.filter_by(
+ get_creator=url_user)
+
+ pagination = Pagination(page, collections)
+
+ return render_to_response(
+ request,
+ 'mediagoblin/user_pages/collections.html',
+ {'user': url_user,
+ 'collections': collections,
+ 'pagination': pagination})
+
+
@get_user_collection_item
@require_active_login
@user_may_alter_collection