Skip to content

Commit

Permalink
Fix broken filtering on documents page
Browse files Browse the repository at this point in the history
Introduced in 35495e7. The reset link was also hardcoded for
the documents view.
  • Loading branch information
friedelwolff committed Aug 15, 2024
1 parent 1f1dfa0 commit 7e79963
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/general/tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ def test_view_basics(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'id="main-heading"')
self.assertIn("documents", response.context)

def test_with_filters(self):
response = self.client.get(reverse("documents"), {"language": self.language3.id})
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["documents"]), 1)
self.assertEqual(response.context["documents"][0]["document"].title, "Document 6")
4 changes: 2 additions & 2 deletions app/templates/app/_subj_lang_institution_filter.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% spaceless %}
<form method="GET" action="" class="mb-3">
<form method="GET" action="{% url view %}" class="mb-3">
<div class="d-flex flex-wrap gap-2">
<div class="form-group flex-fill mb-2">
<label for="subject">{% trans "Subject" %}</label>
Expand Down Expand Up @@ -41,7 +41,7 @@
</div>
<div class="d-flex flex-wrap">
<button type="submit" class="btn btn-primary mt-2 me-2">{% trans "Filter" %}</button>
<a href="{% url 'documents' %}" class="btn btn-secondary mt-2">{% trans "Reset" %}</a>
<a href="{% url view %}" class="btn btn-secondary mt-2">{% trans "Reset" %}</a>
</div>
</form>
{% endspaceless %}
2 changes: 1 addition & 1 deletion app/templates/app/documents.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="text-break m-4">
<h1 id="main-heading">{% trans "Documents" %}</h1>

{% include "app/_subj_lang_institution_filter.html" %}
{% include "app/_subj_lang_institution_filter.html" with view="documents"%}

{% for item in documents %}
<div class="mt-4">{# additional indent simplifies comparison with projects.html #}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/app/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="text-break m-4">
<h1 id="main-heading">{% trans "Projects" %}</h1>

{% include "app/_subj_lang_institution_filter.html" %}
{% include "app/_subj_lang_institution_filter.html" with view="projects" %}

{% for item in projects %}
<div class="container-fluid mt-4 mb-5 p-0">{# container adds unwanted padding #}
Expand Down

0 comments on commit 7e79963

Please sign in to comment.