From 7e79963de67507ed8008a0df0de1def9d03b82ce Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Thu, 15 Aug 2024 15:43:03 +0200 Subject: [PATCH] Fix broken filtering on documents page Introduced in 35495e7dc04. The reset link was also hardcoded for the documents view. --- app/general/tests/test_documents.py | 6 ++++++ app/templates/app/_subj_lang_institution_filter.html | 4 ++-- app/templates/app/documents.html | 2 +- app/templates/app/projects.html | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/general/tests/test_documents.py b/app/general/tests/test_documents.py index dd2d2fe0..6d6f1d46 100644 --- a/app/general/tests/test_documents.py +++ b/app/general/tests/test_documents.py @@ -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") diff --git a/app/templates/app/_subj_lang_institution_filter.html b/app/templates/app/_subj_lang_institution_filter.html index de3e81ce..158ea7e6 100644 --- a/app/templates/app/_subj_lang_institution_filter.html +++ b/app/templates/app/_subj_lang_institution_filter.html @@ -1,6 +1,6 @@ {% load i18n %} {% spaceless %} -
+
@@ -41,7 +41,7 @@
- {% trans "Reset" %} + {% trans "Reset" %}
{% endspaceless %} diff --git a/app/templates/app/documents.html b/app/templates/app/documents.html index 67e56dbc..ecb18399 100644 --- a/app/templates/app/documents.html +++ b/app/templates/app/documents.html @@ -10,7 +10,7 @@

{% trans "Documents" %}

- {% include "app/_subj_lang_institution_filter.html" %} + {% include "app/_subj_lang_institution_filter.html" with view="documents"%} {% for item in documents %}
{# additional indent simplifies comparison with projects.html #} diff --git a/app/templates/app/projects.html b/app/templates/app/projects.html index 7b90439a..64a21c6a 100644 --- a/app/templates/app/projects.html +++ b/app/templates/app/projects.html @@ -10,7 +10,7 @@

{% trans "Projects" %}

- {% include "app/_subj_lang_institution_filter.html" %} + {% include "app/_subj_lang_institution_filter.html" with view="projects" %} {% for item in projects %}
{# container adds unwanted padding #}