diff --git a/core/jinja2_handler.py b/core/jinja2_handler.py index 894b8cfcd..8b7db69a6 100644 --- a/core/jinja2_handler.py +++ b/core/jinja2_handler.py @@ -12,18 +12,6 @@ from qfdmo.models.action import get_actions_by_direction -def is_embedded(request: HttpRequest) -> bool: - return "iframe" in request.GET or "carte" in request.GET - - -def is_carte(request: HttpRequest) -> bool: - return "carte" in request.GET - - -def is_iframe(request: HttpRequest) -> bool: - return "iframe" in request.GET - - def action_by_direction(request: HttpRequest, direction: str): requested_direction = get_direction(request) action_displayed = request.GET.get("action_displayed", "") @@ -89,9 +77,6 @@ def environment(**options): "hide_object_filter": hide_object_filter, "distance_to_acteur": distance_to_acteur, "display_exclusivite_reparation": display_exclusivite_reparation, - "is_embedded": is_embedded, - "is_iframe": is_iframe, - "is_carte": is_carte, "url": reverse, "static": static, "quote_plus": lambda u: quote_plus(u), diff --git a/jinja2/layout/base.html b/jinja2/layout/base.html index bb1e2b5a2..768ae6f8b 100644 --- a/jinja2/layout/base.html +++ b/jinja2/layout/base.html @@ -26,7 +26,7 @@ {% block javascript_extras %}{% endblock %} - {% if is_embedded(request) %} + {% if is_embedded %} {% endif %} @@ -35,7 +35,7 @@ class="qfdmo-flex qfdmo-flex-col" data-controller="analytics" > - {% if not is_embedded(request) %} + {% if not is_embedded %} {% block header %} {% include "layout/header.html" %} {% endblock %} @@ -58,14 +58,14 @@

Une mise à jour de votre navigateur est nécessaire {% block content %}{% endblock %} - {% if not is_embedded(request) %} + {% if not is_embedded %} {% block footer %} {% include "layout/footer.html" %} {% endblock %} {% endif %} {% block js %} {% endblock %} - {% if is_embedded(request) %} + {% if is_embedded %} diff --git a/jinja2/qfdmo/_addresses_partials/adresse_input_form.html b/jinja2/qfdmo/_addresses_partials/adresse_input_form.html index e68d6b212..0ad353142 100644 --- a/jinja2/qfdmo/_addresses_partials/adresse_input_form.html +++ b/jinja2/qfdmo/_addresses_partials/adresse_input_form.html @@ -3,9 +3,9 @@
diff --git a/jinja2/qfdmo/_addresses_partials/filters/_object_filter.html b/jinja2/qfdmo/_addresses_partials/filters/_object_filter.html index 39555f0ae..d5983b5d9 100644 --- a/jinja2/qfdmo/_addresses_partials/filters/_object_filter.html +++ b/jinja2/qfdmo/_addresses_partials/filters/_object_filter.html @@ -2,9 +2,9 @@
{{ form.sous_categorie_objet.label_tag() }} diff --git a/jinja2/qfdmo/_addresses_partials/filters/panel_filters.html b/jinja2/qfdmo/_addresses_partials/filters/panel_filters.html index 664b65242..c7c4cf7de 100644 --- a/jinja2/qfdmo/_addresses_partials/filters/panel_filters.html +++ b/jinja2/qfdmo/_addresses_partials/filters/panel_filters.html @@ -66,7 +66,7 @@

type="button" data-action="click -> search-solution-form#advancedSubmit" data-without-zone="false" - data-with-controls={{"false" if is_carte(request) else "true"}} + data-with-controls={{"false" if is_carte else "true"}} data-toggle-advanced-filters="true" > Appliquer diff --git a/jinja2/qfdmo/_addresses_partials/iframe_footer_links.html b/jinja2/qfdmo/_addresses_partials/iframe_footer_links.html index e0edfc20f..4e1d515f8 100644 --- a/jinja2/qfdmo/_addresses_partials/iframe_footer_links.html +++ b/jinja2/qfdmo/_addresses_partials/iframe_footer_links.html @@ -1,5 +1,5 @@ {# Liens de pieds de page pour iframe #} -{% if is_embedded(request) %} +{% if is_embedded %}

{% for service_proposition in adresse.proposition_services_by_direction(direction) %}
-

+

{% if service_proposition.action.icon %} -   +   {% endif %} {{ service_proposition.action.libelle }}

diff --git a/jinja2/qfdmo/carte/panels/legend_mobile.html b/jinja2/qfdmo/carte/panels/legend_mobile.html index ef196f7eb..197ac6aa5 100644 --- a/jinja2/qfdmo/carte/panels/legend_mobile.html +++ b/jinja2/qfdmo/carte/panels/legend_mobile.html @@ -32,7 +32,7 @@

type="button" data-action="click -> search-solution-form#advancedSubmit" data-without-zone="false" - data-with-controls={{"false" if is_carte(request) else "true"}} + data-with-controls={{"false" if is_carte else "true"}} data-toggle-advanced-filters="true" > Appliquer diff --git a/jinja2/qfdmo/partials/featureflip_inputs.html b/jinja2/qfdmo/partials/featureflip_inputs.html index 765c23d41..ab6d6c070 100644 --- a/jinja2/qfdmo/partials/featureflip_inputs.html +++ b/jinja2/qfdmo/partials/featureflip_inputs.html @@ -1,7 +1,7 @@ -{% if is_iframe(request) %} +{% if is_iframe %} {% endif %} -{% if is_carte(request) %} +{% if is_carte %} {% endif %} {% if request.GET.get('limit') %} diff --git a/jinja2/qfdmo/shared/_layout.html b/jinja2/qfdmo/shared/_layout.html index 82f41c72f..639e87750 100644 --- a/jinja2/qfdmo/shared/_layout.html +++ b/jinja2/qfdmo/shared/_layout.html @@ -8,8 +8,8 @@ {% include "qfdmo/shared/_search_form_data-attributes.html" %} class=" qfdmo-min-h-screen - qfdmo-flex qfdmo-flex-col qfdmo-flex-auto - qfdmo-relative" + qfdmo-flex qfdmo-flex-col qfdmo-flex-auto + qfdmo-relative" > {% include "qfdmo/partials/featureflip_inputs.html" %} diff --git a/jinja2/qfdmo/shared/_map_container.html b/jinja2/qfdmo/shared/_map_container.html index 1c9a2bf74..e5b4da749 100644 --- a/jinja2/qfdmo/shared/_map_container.html +++ b/jinja2/qfdmo/shared/_map_container.html @@ -17,7 +17,7 @@ > {{ form.bounding_box }}
- {% if is_carte(request) %} + {% if is_carte %} {% endif %} {% include "qfdmo/shared/disclaimers/loading_solutions.html" %} -{% if not is_carte(request) %} +{% if not is_carte %}
{% block panel_header %} diff --git a/jinja2/qfdmo/shared/_search_form_data-attributes.html b/jinja2/qfdmo/shared/_search_form_data-attributes.html index 3d5824e82..559b76b0e 100644 --- a/jinja2/qfdmo/shared/_search_form_data-attributes.html +++ b/jinja2/qfdmo/shared/_search_form_data-attributes.html @@ -1,6 +1,6 @@ data-controller="search-solution-form" id='search_form' data-search-solution-form-target="searchForm" -data-search-solution-form-is-iframe-value="{{ is_embedded(request) }}" +data-search-solution-form-is-iframe-value="{{ is_embedded }}" data-turbo-frame="addressesPanel" data-action="map:displayActeur->search-solution-form#displayActeur map:updateBbox->search-solution-form#updateBboxInput diff --git a/jinja2/qfdmo/shared/_search_in_zone.html b/jinja2/qfdmo/shared/_search_in_zone.html index 7314e910a..c4f04a104 100644 --- a/jinja2/qfdmo/shared/_search_in_zone.html +++ b/jinja2/qfdmo/shared/_search_in_zone.html @@ -5,7 +5,7 @@ class="fr-btn fr-btn--sm fr-btn--secondary fr-m-1w fr-p-1v qfdmo-absolute qfdmo-z-[1010] qfdmo-right-0 qfdmo-hidden qfdmo-bg-white" type="button" - data-with-controls={{"false" if is_carte(request) else "true"}} + data-with-controls={{"false" if is_carte else "true"}} data-testid="searchInZone" > Rechercher dans cette zone diff --git a/jinja2/qfdmo/shared/disclaimers/no_local_solution.html b/jinja2/qfdmo/shared/disclaimers/no_local_solution.html index 462e4a086..fe2d03dee 100644 --- a/jinja2/qfdmo/shared/disclaimers/no_local_solution.html +++ b/jinja2/qfdmo/shared/disclaimers/no_local_solution.html @@ -2,7 +2,7 @@ class="qfdmo-absolute qfdmo-inset-0 qfdmo-bg-white qfdmo-opacity-80 qfdmo-font-black qfdmo-z-[1020] {% if acteurs or not address_ok %} qfdmo-hidden{% endif %}" data-search-solution-form-target="NoLocalSolution" > -
+
Il n'existe pas de solution {% if bounding_box %}dans cette zone{% else %}localisée proche de chez vous (<30 km){% endif %}, essayez avec une autre combinaison de filtres.
diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index 8f96f49a9..8d37cb1a7 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -48,7 +48,7 @@ BAN_API_URL = "https://api-adresse.data.gouv.fr/search/?q={}" -class TurboFormView(FormView): +class TurboFormMixin: def setup(self, request, *args, **kwargs): super().setup(request, *args, **kwargs) self.turbo = request.headers.get("Turbo-Frame") @@ -64,7 +64,28 @@ def get_context_data(self, **kwargs): return context -class CarteView(TurboFormView, FormView): +class IframeMixin: + @property + def is_embedded(self): + return self.is_carte or self.is_iframe + + def setup(self, request, *args, **kwargs): + super().setup(request, *args, **kwargs) + self.is_carte = "carte" in request.GET + self.is_iframe = "iframe" in request.GET + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update( + is_carte=self.is_carte, + is_iframe=self.is_iframe, + is_embedded=self.is_embedded, + ) + + return context + + +class CarteView(TurboFormMixin, IframeMixin, FormView): template_name = "qfdmo/carte.html" def get_initial(self): @@ -119,8 +140,6 @@ def get_initial(self): def setup(self, request, *args, **kwargs): super().setup(request, *args, **kwargs) - - self.is_carte = request.GET.get("carte") is not None if self.is_carte: self.form_class = CarteForm else: