Skip to content

Commit

Permalink
contacts: Don't mix contacts and contactsraw
Browse files Browse the repository at this point in the history
The template personal/list is used by contacts and contactsraw. However
the group filter uses the absolut url {% url 'contacts' %} which jumps back
to reverse mapping of "contacts". Additionally, "name="contacts" was
registered for both urlpatterns /contacts and /contactsraw, so it
resolves to /contactsraw. This makes us effectively jump to contactsraw
whenever the group filter is changed.

Give /contacts and /contactsraw urlpatterns different name attributes.

Use relative URLs with just a replaced query string for the group
filter links.
  • Loading branch information
donald committed Nov 1, 2019
1 parent 5707f31 commit e9917fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
path('api/v2/', api_router.urls),
path('logout', LogoutView.as_view(), name='logout'),
path('contacts/', ContactListView.as_view(), name='contacts'),
path('contactsraw/', RawContactListView.as_view(), name='contacts'),
path('contactsraw/', RawContactListView.as_view(), name='contactsraw'),

path('events/ics', ics_view, name='ics')
] + static(
Expand Down
4 changes: 2 additions & 2 deletions mpicms/templates/personal/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ <h1 class="title has-text-centered">{% trans 'Contact List' %}</h1>
<div class="dropdown-content">

{% for group in groups %}
<a href="{% url 'contacts' %}?group={{ group.pk }}" class="{% if group.pk|stringformat:'d' == request.GET.group %}is-active {% endif %}dropdown-item">
<a href="?group={{ group.pk }}" class="{% if group.pk|stringformat:'d' == request.GET.group %}is-active {% endif %}dropdown-item">
{{ group }}
</a>
{% endfor %}

<hr class="dropdown-divider">
<a href="{% url 'contacts' %}" class="dropdown-item">
<a href="?" class="dropdown-item">
{% trans 'Reset filter' %}
</a>
</div>
Expand Down

0 comments on commit e9917fd

Please sign in to comment.