Make pagination on user profile point to the user gallery
This required a couple of changes: - making a new render_pagination macro - switching things over to use that
This commit is contained in:
parent
d729012dd9
commit
5949be9ad6
@ -18,6 +18,7 @@
|
||||
{% extends "mediagoblin/base.html" %}
|
||||
|
||||
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
||||
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
||||
|
||||
{% block mediagoblin_content %}
|
||||
{% if media %}
|
||||
@ -87,7 +88,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% include "mediagoblin/utils/pagination.html" %}
|
||||
{{ render_pagination(request, pagination) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="grid_4 omega media_sidebar">
|
||||
|
@ -30,14 +30,14 @@
|
||||
|
||||
{% include "mediagoblin/utils/profile.html" %}
|
||||
|
||||
{% set pagination_base_url = user_gallery_url %}
|
||||
{% include "mediagoblin/utils/object_gallery.html" %}
|
||||
|
||||
<p><a href="{{ request.urlgen('mediagoblin.user_pages.user_gallery',
|
||||
user=user['username']) }}">View all of {{ user.username }}'s media</a></p>
|
||||
<p><a href="user_gallery_url">View all of {{ user.username }}'s media</a></p>
|
||||
|
||||
<a href={{ request.urlgen(
|
||||
'mediagoblin.user_pages.atom_feed',
|
||||
user=user.username) }}> atom feed</a>
|
||||
user=user.username) }}>atom feed</a>
|
||||
{% else %}
|
||||
{# This *should* not occur as the view makes sure we pass in a user. #}
|
||||
<p>Sorry, no such user found.<p/>
|
||||
|
@ -16,6 +16,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
||||
|
||||
{% block object_gallery_content -%}
|
||||
<div>
|
||||
{% if media_entries %}
|
||||
@ -28,8 +30,12 @@
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% include "mediagoblin/utils/pagination.html" %}
|
||||
{% endif %}
|
||||
|
||||
{% if pagination_base_url %}
|
||||
{# different url, so set that and don't keep the get params #}
|
||||
{{ render_pagination(request, pagination, pagination_base_url, False) }}
|
||||
{% else %}
|
||||
{{ render_pagination(request, pagination) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -15,31 +15,48 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{# only display if {{pagination}} is defined #}
|
||||
{% macro render_pagination(request, pagination,
|
||||
base_url=None, preserve_get_params=True) %}
|
||||
{# only display if {{pagination}} is defined #}
|
||||
{% if pagination and pagination.pages > 1 %}
|
||||
{% if not base_url %}
|
||||
{% set base_url = request.path_info %}
|
||||
{% endif %}
|
||||
|
||||
{% if pagination and pagination.pages > 1 %}
|
||||
<div class="pagination">
|
||||
<p>
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ pagination.get_page_url(request, pagination.page-1) }}">« Prev</a>
|
||||
{% endif %}
|
||||
{% if preserve_get_params %}
|
||||
{% set get_params = request.GET %}
|
||||
{% else %}
|
||||
{% set get_params = {} %}
|
||||
{% endif %}
|
||||
|
||||
{%- for page in pagination.iter_pages() %}
|
||||
{% if page %}
|
||||
{% if page != pagination.page %}
|
||||
<a href="{{ pagination.get_page_url(request, page) }}">{{ page }}</a>
|
||||
{% else %}
|
||||
{{ page }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="ellipsis">…</span>
|
||||
<div class="pagination">
|
||||
<p>
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ pagination.get_page_url_explicit(
|
||||
base_url, get_params,
|
||||
pagination.page - 1) }}">« Prev</a>
|
||||
{% endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ pagination.get_page_url(request, pagination.page + 1) }}">Next »</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{%- for page in pagination.iter_pages() %}
|
||||
{% if page %}
|
||||
{% if page != pagination.page %}
|
||||
<a href="{{ pagination.get_page_url_explicit(
|
||||
base_url, get_params,
|
||||
page) }}">{{ page }}</a>
|
||||
{% else %}
|
||||
{{ page }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="ellipsis">…</span>
|
||||
{% endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ pagination.get_page_url_explicit(
|
||||
base_url, get_params,
|
||||
pagination.page + 1) }}">Next »</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
@ -48,10 +48,15 @@ def user_home(request, page):
|
||||
if media_entries == None:
|
||||
return exc.HTTPNotFound()
|
||||
|
||||
user_gallery_url = request.urlgen(
|
||||
'mediagoblin.user_pages.user_gallery',
|
||||
user=user['username'])
|
||||
|
||||
return render_to_response(
|
||||
request,
|
||||
'mediagoblin/user_pages/user.html',
|
||||
{'user': user,
|
||||
'user_gallery_url': user_gallery_url,
|
||||
'media_entries': media_entries,
|
||||
'pagination': pagination})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user