Ticket #526: 0001-collections-add-support-to-browse-existing-collectio.patch
File 0001-collections-add-support-to-browse-existing-collectio.patch, 5.8 KB (added by , 12 years ago) |
---|
-
mediagoblin/templates/mediagoblin/root.html
From 43b19534536225812b728ff3469f435a0549d4bc Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli <zack@upsilon.cc> Date: Tue, 18 Dec 2012 12:34:30 +0100 Subject: [PATCH] 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 --- mediagoblin/templates/mediagoblin/root.html | 7 ++- .../mediagoblin/user_pages/collections.html | 63 ++++++++++++++++++++ mediagoblin/user_pages/routing.py | 4 ++ mediagoblin/user_pages/views.py | 17 ++++++ 4 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 mediagoblin/templates/mediagoblin/user_pages/collections.html diff --git a/mediagoblin/templates/mediagoblin/root.html b/mediagoblin/templates/mediagoblin/root.html index 047dd2b..0be6c9f 100644
a b 27 27 <li><a href="{{ request.urlgen('mediagoblin.submit.start') }}"> 28 28 {%- trans %}Add media{% endtrans -%} 29 29 </a></li> 30 <li><a href="{{ request.urlgen('mediagoblin.submit.collection') }}"> 31 {%- trans %}Create new collection{% endtrans -%} 32 </a></li> 30 <li><a href="{{ request.urlgen('mediagoblin.user_pages.user_collections', 31 user=request.user.username) }}"> 32 {%- trans %}Browse collections{% endtrans -%} 33 </a></li> 33 34 <li><a href="{{ request.urlgen('mediagoblin.edit.account') }}"> 34 35 {%- trans %}Change account settings{% endtrans -%} 35 36 </a></li> -
new file mediagoblin/templates/mediagoblin/user_pages/collections.html
diff --git a/mediagoblin/templates/mediagoblin/user_pages/collections.html b/mediagoblin/templates/mediagoblin/user_pages/collections.html new file mode 100644 index 0000000..7548b5a
- + 1 {# 2 # GNU MediaGoblin -- federated, autonomous media hosting 3 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU Affero General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Affero General Public License for more details. 14 # 15 # You should have received a copy of the GNU Affero General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 #} 18 {% extends "mediagoblin/base.html" %} 19 20 {% block mediagoblin_head %} 21 <link rel="alternate" type="application/atom+xml" 22 href="{{ request.urlgen( 23 'mediagoblin.user_pages.atom_feed', 24 user=user.username) }}"> 25 {% endblock mediagoblin_head %} 26 27 {% block title %} 28 {%- trans username=user.username -%} 29 {{ username }}'s collections 30 {%- endtrans %} — {{ super() }} 31 {% endblock %} 32 33 {% block mediagoblin_content -%} 34 <h1> 35 {%- trans username=user.username, 36 user_url=request.urlgen( 37 'mediagoblin.user_pages.user_home', 38 user=user.username) -%} 39 <a href="{{ user_url }}">{{ username }}</a>'s collections 40 {%- endtrans %} 41 </h1> 42 43 {% if request.user %} 44 {% if request.user.status == 'active' %} 45 <p> 46 <a href="{{ request.urlgen('mediagoblin.submit.collection', 47 user=user.username) }}"> 48 {%- trans %}Create new collection{% endtrans -%} 49 </p> 50 {% endif %} 51 {% endif %} 52 53 <ul> 54 {% for coll in collections %} 55 {% set coll_url = request.urlgen( 56 'mediagoblin.user_pages.user_collection', 57 user=user.username, 58 collection=coll.slug) %} 59 <li><a href="{{ coll_url }}">{{ coll.title }}</li> 60 {% endfor %} 61 </ul> 62 63 {% endblock %} -
mediagoblin/user_pages/routing.py
diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index 8162e64..b7f7175 100644
a b add_route('mediagoblin.user_pages.media_collect', 47 47 '/u/<string:user>/m/<string:media>/collect/', 48 48 'mediagoblin.user_pages.views:media_collect') 49 49 50 add_route('mediagoblin.user_pages.user_collections', 51 '/u/<string:user>/collections/', 52 'mediagoblin.user_pages.views:user_collections') 53 50 54 add_route('mediagoblin.user_pages.user_collection', 51 55 '/u/<string:user>/collection/<string:collection>/', 52 56 'mediagoblin.user_pages.views:user_collection') -
mediagoblin/user_pages/views.py
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index cbf3f15..78140ea 100644
a b def user_collection(request, page, url_user=None): 346 346 'pagination': pagination}) 347 347 348 348 349 @active_user_from_url 350 @uses_pagination 351 def user_collections(request, page, url_user=None): 352 """A User-defined Collection""" 353 collections = Collection.query.filter_by( 354 get_creator=url_user) 355 356 pagination = Pagination(page, collections) 357 358 return render_to_response( 359 request, 360 'mediagoblin/user_pages/collections.html', 361 {'user': url_user, 362 'collections': collections, 363 'pagination': pagination}) 364 365 349 366 @get_user_collection_item 350 367 @require_active_login 351 368 @user_may_alter_collection