From: Christopher Allan Webber Date: Sun, 3 Jul 2011 03:09:46 +0000 (-0500) Subject: Make pagination on user profile point to the user gallery X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5949be9ad686b161b6c63696d9b0f5f1cff932d9;p=mediagoblin.git 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 --- 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})