From b30725d9875052ab53de9e915edc1138ff4c40c3 Mon Sep 17 00:00:00 2001 From: Binnette Date: Sun, 1 Mar 2020 10:56:02 +0100 Subject: [PATCH] Fix annoying exception thrown on home page --- umap/templates/auth/user_detail.html | 2 +- umap/templates/umap/home.html | 2 +- umap/templates/umap/map_list.html | 2 +- umap/templates/umap/search_bar.html | 6 +++++- umap/templatetags/umap_tags.py | 6 +++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/umap/templates/auth/user_detail.html b/umap/templates/auth/user_detail.html index 363b1529..1eb6bc5e 100644 --- a/umap/templates/auth/user_detail.html +++ b/umap/templates/auth/user_detail.html @@ -9,7 +9,7 @@
{% if maps %} - {% include "umap/map_list.html" %} + {% include "umap/map_list.html" with prefix='user_detail' %} {% else %}
{% blocktrans %}{{ current_user }} has no maps.{% endblocktrans %} diff --git a/umap/templates/umap/home.html b/umap/templates/umap/home.html index b405786e..54fe1b57 100644 --- a/umap/templates/umap/home.html +++ b/umap/templates/umap/home.html @@ -23,7 +23,7 @@

{% blocktrans %}Get inspired, browse maps{% endblocktrans %}

- {% include "umap/map_list.html" %} + {% include "umap/map_list.html" with prefix='home' %}
diff --git a/umap/templates/umap/map_list.html b/umap/templates/umap/map_list.html index 672aa6a8..47138fde 100644 --- a/umap/templates/umap/map_list.html +++ b/umap/templates/umap/map_list.html @@ -3,7 +3,7 @@ {% for map_inst in maps %}
- {% map_fragment map_inst prefix=prefix page=request.GET.p %} + {% map_fragment map_inst prefix=prefix params=request.GET %}
{{ map_inst.name }}{% if map_inst.owner %} {% trans "by" %} {{ map_inst.owner }}{% endif %}
{% endfor %} diff --git a/umap/templates/umap/search_bar.html b/umap/templates/umap/search_bar.html index 67b84c28..cf09137e 100644 --- a/umap/templates/umap/search_bar.html +++ b/umap/templates/umap/search_bar.html @@ -3,7 +3,11 @@
- + {% if q %} + + {% else %} + + {% endif %}
diff --git a/umap/templatetags/umap_tags.py b/umap/templatetags/umap_tags.py index c40691d1..ed4a06f7 100644 --- a/umap/templatetags/umap_tags.py +++ b/umap/templatetags/umap_tags.py @@ -51,7 +51,11 @@ def map_fragment(map_instance, **kwargs): }) map_settings['properties'].update(kwargs) prefix = kwargs.pop('prefix', None) or 'map' - page = kwargs.pop('page', None) or '' + params = kwargs.pop('params', None) + if params is not None and params.__contains__('p'): + page = params.p + else: + page = '' unique_id = prefix + str(page) + "_" + str(map_instance.pk) return { "map_settings": json.dumps(map_settings),