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
This commit is contained in:
parent
cf764377df
commit
b0cc1ade40
@ -27,9 +27,10 @@
|
||||
<li><a href="{{ request.urlgen('mediagoblin.submit.start') }}">
|
||||
{%- trans %}Add media{% endtrans -%}
|
||||
</a></li>
|
||||
<li><a href="{{ request.urlgen('mediagoblin.submit.collection') }}">
|
||||
{%- trans %}Create new collection{% endtrans -%}
|
||||
</a></li>
|
||||
<li><a href="{{ request.urlgen('mediagoblin.user_pages.user_collections',
|
||||
user=request.user.username) }}">
|
||||
{%- trans %}Browse collections{% endtrans -%}
|
||||
</a></li>
|
||||
<li><a href="{{ request.urlgen('mediagoblin.edit.account') }}">
|
||||
{%- trans %}Change account settings{% endtrans -%}
|
||||
</a></li>
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
{% extends "mediagoblin/base.html" %}
|
||||
|
||||
{% block mediagoblin_head %}
|
||||
<link rel="alternate" type="application/atom+xml"
|
||||
href="{{ request.urlgen(
|
||||
'mediagoblin.user_pages.atom_feed',
|
||||
user=user.username) }}">
|
||||
{% endblock mediagoblin_head %}
|
||||
|
||||
{% block title %}
|
||||
{%- trans username=user.username -%}
|
||||
{{ username }}'s collections
|
||||
{%- endtrans %} — {{ super() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mediagoblin_content -%}
|
||||
<h1>
|
||||
{%- trans username=user.username,
|
||||
user_url=request.urlgen(
|
||||
'mediagoblin.user_pages.user_home',
|
||||
user=user.username) -%}
|
||||
<a href="{{ user_url }}">{{ username }}</a>'s collections
|
||||
{%- endtrans %}
|
||||
</h1>
|
||||
|
||||
{% if request.user %}
|
||||
{% if request.user.status == 'active' %}
|
||||
<p>
|
||||
<a href="{{ request.urlgen('mediagoblin.submit.collection',
|
||||
user=user.username) }}">
|
||||
{%- trans %}Create new collection{% endtrans -%}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<ul>
|
||||
{% for coll in collections %}
|
||||
{% set coll_url = request.urlgen(
|
||||
'mediagoblin.user_pages.user_collection',
|
||||
user=user.username,
|
||||
collection=coll.slug) %}
|
||||
<li><a href="{{ coll_url }}">{{ coll.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user