Add test for get_all_media()
[mediagoblin.git] / mediagoblin / templates / mediagoblin / utils / collection_gallery.html
CommitLineData
a0fdc00f
AW
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
19{% from "mediagoblin/utils/pagination.html" import render_pagination %}
20
21{% macro media_grid(request, collection_items, col_number=5) %}
da77b8e9 22 <div class="thumb_gallery">
2222278d 23 {% for row in collection_items|batch(col_number) %}
da77b8e9 24 <div class="row thumb_row
a0fdc00f
AW
25 {%- if loop.first %} thumb_row_first
26 {%- elif loop.last %} thumb_row_last{% endif %}">
27 {% for item in row %}
0f3bf8d4
JT
28 {% set obj = item.get_object() %}
29 {% set obj_url = obj.url_for_self(request.urlgen) %}
da77b8e9 30 <div class="three columns media_thumbnail thumb_entry
a0fdc00f
AW
31 {%- if loop.first %} thumb_entry_first
32 {%- elif loop.last %} thumb_entry_last{% endif %}">
0f3bf8d4 33 <a href="{{ obj_url }}">
be44e006
AB
34 {% if obj.icon_url %}
35 <img class="entry_type_icon" src="{{ obj.icon_url }}" />
36 {% endif %}
0f3bf8d4 37 <img src="{{ obj.thumb_url }}" />
a0fdc00f 38 </a>
2e4ad359 39
df2de8e2
BB
40 {% if obj.title %}
41 <a href="{{ obj_url }}">{{ obj.title }}</a>
42 {% endif %}
a0fdc00f 43 {% if item.note %}
df2de8e2 44 {{ item.note }}
a0fdc00f
AW
45 {% endif %}
46 {% if request.user and
0f3bf8d4 47 (item.in_collection.actor == request.user.id or
f1bf5ccd 48 request.user.has_privilege('admin')) %}
32255ec0 49 {%- set remove_url=request.urlgen(
a0fdc00f 50 'mediagoblin.user_pages.collection_item_confirm_remove',
0f3bf8d4 51 user=item.in_collection.get_actor.username,
a0fdc00f
AW
52 collection=item.in_collection.slug,
53 collection_item=item.id) -%}
32255ec0
E
54 <a href="{{ remove_url }}" class="remove">
55 {%- trans %}(remove){% endtrans -%}
56 </a>
a0fdc00f 57 {% endif %}
da77b8e9 58 </div>
a0fdc00f 59 {% endfor %}
da77b8e9 60 </div>
a0fdc00f 61 {% endfor %}
da77b8e9 62 </div>
a0fdc00f
AW
63{%- endmacro %}
64
65{#
66 Render a media gallery with pagination.
67
68 Args:
69 - request: Request
70 - collection_items: cursor of collection items
71 - pagination: Paginator object
72 - pagination_base_url: If you want the pagination to point to a
73 different URL, point it here
74 - col_number: How many columns per row (default 5)
75#}
76{% macro collection_gallery(request, collection_items, pagination,
77 pagination_base_url=None, col_number=5) %}
78 {% if collection_items and collection_items.count() %}
79 {{ media_grid(request, collection_items, col_number=col_number) }}
80 <div class="clear"></div>
81 {% if pagination_base_url %}
82 {# different url, so set that and don't keep the get params #}
83 {{ render_pagination(request, pagination, pagination_base_url, False) }}
84 {% else %}
85 {{ render_pagination(request, pagination) }}
86 {% endif %}
87 {% else %}
88 <p>
89 <i>
90 {%- trans -%}
91 There doesn't seem to be any media here yet...
92 {%- endtrans -%}
93 </i>
94 </p>
95 {% endif %}
96{% endmacro %}