From b0cc1ade404417a3b4c005ac4e11d5f71ac0c988 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 18 Dec 2012 12:34:30 +0100 Subject: [PATCH] collections: add support to browse existing collections - add a route at /u//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 047dd2bb..0be6c9f4 100644 --- a/mediagoblin/templates/mediagoblin/root.html +++ b/mediagoblin/templates/mediagoblin/root.html @@ -27,9 +27,10 @@
  • {%- trans %}Add media{% endtrans -%}
  • -
  • - {%- trans %}Create new collection{% endtrans -%} -
  • +
  • + {%- trans %}Browse collections{% endtrans -%} +
  • {%- trans %}Change account settings{% endtrans -%}
  • diff --git a/mediagoblin/templates/mediagoblin/user_pages/collections.html b/mediagoblin/templates/mediagoblin/user_pages/collections.html new file mode 100644 index 00000000..7548b5a1 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/collections.html @@ -0,0 +1,63 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +#} +{% extends "mediagoblin/base.html" %} + +{% block mediagoblin_head %} + +{% endblock mediagoblin_head %} + +{% block title %} + {%- trans username=user.username -%} + {{ username }}'s collections + {%- endtrans %} — {{ super() }} +{% endblock %} + +{% block mediagoblin_content -%} +

    + {%- trans username=user.username, + user_url=request.urlgen( + 'mediagoblin.user_pages.user_home', + user=user.username) -%} + {{ username }}'s collections + {%- endtrans %} +

    + + {% if request.user %} + {% if request.user.status == 'active' %} +

    + + {%- trans %}Create new collection{% endtrans -%} +

    + {% endif %} + {% endif %} + + + +{% endblock %} 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//m//collect/', 'mediagoblin.user_pages.views:media_collect') +add_route('mediagoblin.user_pages.user_collections', + '/u//collections/', + 'mediagoblin.user_pages.views:user_collections') + add_route('mediagoblin.user_pages.user_collection', '/u//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 -- 2.25.1