Skip to content

Commit 798d9fa

Browse files
Corrige une régression sur les cartes sur mesure sans sous-catégorie définie (#1949)
1 parent 80cc87f commit 798d9fa

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

integration_tests/carte/test_use_carte_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,26 @@ def test_preview_screen(self, get_carte_config_response_and_soup):
6464
assert (
6565
soup.find(attrs={"data-testid": "preview-content"}).text.strip() == "Coucou"
6666
)
67+
68+
def test_cyclevia_regresion(self, get_carte_config_response_and_soup):
69+
"""A regression introduced by adding the CarteConfig as a wagtail block
70+
caused the Cyclevia CarteConfig to fail after a search, because it does
71+
not use any sous_categorie_objet.
72+
This test ensures that the regression is fixed."""
73+
carte_config_without_sous_categories = CarteConfigFactory()
74+
response, soup = get_carte_config_response_and_soup(
75+
carte_config_without_sous_categories.slug,
76+
{
77+
"adresse": "Auray",
78+
"longitude": "-2.990838",
79+
"latitude": "47.668099",
80+
"carte": "",
81+
"r": "55",
82+
"bounding_box": "",
83+
"direction": "",
84+
"action_displayed": "trier",
85+
"sous_categorie_objet": "",
86+
"sc_id": "",
87+
},
88+
)
89+
assert response.status_code == 200

qfdmo/views/carte.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,14 @@ def _grouped_action_from(self, *args, **kwargs):
107107
return super()._grouped_action_from(*args, **kwargs)
108108

109109
def get_sous_categorie_filter(self):
110-
# TODO: Revoir nommage + documenter
111-
if sous_categorie_filter := self.request.GET.getlist(
112-
CarteConfig.SOUS_CATEGORIE_QUERY_PARAM
113-
):
114-
return sous_categorie_filter
110+
sous_categories_from_request = list(
111+
filter(
112+
None, self.request.GET.getlist(CarteConfig.SOUS_CATEGORIE_QUERY_PARAM)
113+
)
114+
)
115+
if sous_categories_from_request:
116+
return sous_categories_from_request
117+
115118
return self.get_object().sous_categorie_objet.all().values_list("id", flat=True)
116119

117120
def _compile_acteurs_queryset(self, *args, **kwargs):

0 commit comments

Comments
 (0)