|
5 | 5 | import string
|
6 | 6 | import uuid
|
7 | 7 | from copy import deepcopy
|
8 |
| -from typing import Any, List, cast |
| 8 | +from typing import Any, cast |
9 | 9 | from urllib.parse import urlencode
|
10 | 10 |
|
11 | 11 | import opening_hours
|
@@ -1103,16 +1103,16 @@ def get_absolute_url(self):
|
1103 | 1103 | return reverse("qfdmo:acteur-detail", args=[self.uuid])
|
1104 | 1104 |
|
1105 | 1105 | def acteur_actions(
|
1106 |
| - self, direction=None, actions_codes=None, sous_categorie_id=None |
| 1106 | + self, direction=None, actions_codes=None, sous_categorie_ids=None |
1107 | 1107 | ):
|
1108 | 1108 | pss = self.proposition_services.all()
|
1109 | 1109 | # Cast needed because of the cache
|
1110 | 1110 | cached_action_instances = cast(
|
1111 |
| - List[Action], cache.get_or_set("_action_instances", get_action_instances) |
| 1111 | + list[Action], cache.get_or_set("_action_instances", get_action_instances) |
1112 | 1112 | )
|
1113 | 1113 |
|
1114 |
| - if sous_categorie_id: |
1115 |
| - pss = pss.filter(sous_categories__id__in=[sous_categorie_id]) |
| 1114 | + if sous_categorie_ids: |
| 1115 | + pss = pss.filter(sous_categories__id__in=sous_categorie_ids) |
1116 | 1116 | if direction:
|
1117 | 1117 | pss = pss.filter(action__directions__code__in=[direction])
|
1118 | 1118 | if actions_codes:
|
@@ -1166,14 +1166,20 @@ def json_acteur_for_display(
|
1166 | 1166 | carte: bool = False,
|
1167 | 1167 | carte_config: CarteConfig = None,
|
1168 | 1168 | sous_categorie_id: str | None = None,
|
| 1169 | + displayed_acteur_form=None, |
1169 | 1170 | ) -> str:
|
1170 | 1171 | # TODO: refacto jinja: once the shared/results.html template
|
1171 | 1172 | # will be migrated to django template, this method should
|
1172 | 1173 | # live in a template_tags instead.
|
| 1174 | + sous_categorie_ids = [sous_categorie_id] |
| 1175 | + |
| 1176 | + if sous_categories := displayed_acteur_form.cleaned_data.get("sous_categories"): |
| 1177 | + sous_categorie_ids = sous_categories.values_list("id", flat=True) |
| 1178 | + |
1173 | 1179 | actions = self.acteur_actions(
|
1174 | 1180 | direction=direction,
|
1175 | 1181 | actions_codes=action_list,
|
1176 |
| - sous_categorie_id=sous_categorie_id, |
| 1182 | + sous_categorie_ids=sous_categorie_ids, |
1177 | 1183 | )
|
1178 | 1184 |
|
1179 | 1185 | def sort_actions_by_action_principale_and_order(a):
|
|
0 commit comments