From 5949be9ad686b161b6c63696d9b0f5f1cff932d9 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sat, 2 Jul 2011 22:09:46 -0500 Subject: [PATCH] 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 --- .../mediagoblin/user_pages/media.html | 3 +- .../mediagoblin/user_pages/user.html | 6 +- .../mediagoblin/utils/object_gallery.html | 12 +++- .../mediagoblin/utils/pagination.html | 63 ++++++++++++------- mediagoblin/user_pages/views.py | 5 ++ 5 files changed, 59 insertions(+), 30 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 21506ee4..142082ea 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -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 @@ {% endfor %} - {% include "mediagoblin/utils/pagination.html" %} + {{ render_pagination(request, pagination) }} {% endif %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html index 3148043b..b884a1f5 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/user.html +++ b/mediagoblin/templates/mediagoblin/user_pages/user.html @@ -30,14 +30,14 @@ {% include "mediagoblin/utils/profile.html" %} + {% set pagination_base_url = user_gallery_url %} {% include "mediagoblin/utils/object_gallery.html" %} -

View all of {{ user.username }}'s media

+

View all of {{ user.username }}'s media

atom feed + user=user.username) }}>atom feed {% else %} {# This *should* not occur as the view makes sure we pass in a user. #}

Sorry, no such user found.

diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index 8c88c174..4e2886f8 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -16,6 +16,8 @@ # along with this program. If not, see . #} +{% from "mediagoblin/utils/pagination.html" import render_pagination %} + {% block object_gallery_content -%}

{% if media_entries %} @@ -28,8 +30,12 @@ {% endfor %} - {% 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 %}
{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/utils/pagination.html b/mediagoblin/templates/mediagoblin/utils/pagination.html index 7b55b81d..aae50d22 100644 --- a/mediagoblin/templates/mediagoblin/utils/pagination.html +++ b/mediagoblin/templates/mediagoblin/utils/pagination.html @@ -15,31 +15,48 @@ # along with this program. If not, see . #} -{# 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 %} - + {% endif %} +{% endmacro %} diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 012d27a3..3a8684d3 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -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}) -- 2.25.1