From 10aa24cb57f7a62abfb8c2d65e5501b4d6a6b674 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 22 Oct 2024 14:49:46 +0200 Subject: [PATCH 001/109] reorganize template files --- integration_tests/qfdmo/test_adresses_view.py | 8 +-- jinja2/layout/turbo.html | 2 + .../_addresses_partials/carte_result.html | 4 -- jinja2/qfdmo/{adresse => acteur}/detail.html | 0 jinja2/qfdmo/adresse_detail.html | 4 +- jinja2/qfdmo/adresses.html | 61 ------------------- .../_a_propos.html} | 0 .../_filters.html} | 0 .../carte_header.html => carte/_header.html} | 0 .../carte_legend.html => carte/_legend.html} | 0 .../map_and_detail.html => carte/_map.html} | 0 jinja2/qfdmo/carte/_result.html | 4 ++ jinja2/qfdmo/carte/base.html | 51 ++++++++++++++++ .../result.html | 2 +- jinja2/qfdmo/formulaire.html | 41 +++++++++++++ qfdmo/forms.py | 4 +- qfdmo/urls.py | 4 +- qfdmo/views/adresses.py | 28 +++++++-- unit_tests/qfdmo/test_addresses_view.py | 4 +- 19 files changed, 133 insertions(+), 84 deletions(-) create mode 100644 jinja2/layout/turbo.html delete mode 100644 jinja2/qfdmo/_addresses_partials/carte_result.html rename jinja2/qfdmo/{adresse => acteur}/detail.html (100%) delete mode 100644 jinja2/qfdmo/adresses.html rename jinja2/qfdmo/{_addresses_partials/filters/carte_apropos.html => carte/_a_propos.html} (100%) rename jinja2/qfdmo/{_addresses_partials/filters/carte_filters.html => carte/_filters.html} (100%) rename jinja2/qfdmo/{_addresses_partials/carte_header.html => carte/_header.html} (100%) rename jinja2/qfdmo/{_addresses_partials/filters/carte_legend.html => carte/_legend.html} (100%) rename jinja2/qfdmo/{_addresses_partials/map_and_detail.html => carte/_map.html} (100%) create mode 100644 jinja2/qfdmo/carte/_result.html create mode 100644 jinja2/qfdmo/carte/base.html rename jinja2/qfdmo/{_addresses_partials => carte}/result.html (95%) create mode 100644 jinja2/qfdmo/formulaire.html diff --git a/integration_tests/qfdmo/test_adresses_view.py b/integration_tests/qfdmo/test_adresses_view.py index 686579995..94e4c9244 100644 --- a/integration_tests/qfdmo/test_adresses_view.py +++ b/integration_tests/qfdmo/test_adresses_view.py @@ -3,7 +3,7 @@ from django.http import HttpRequest from qfdmo.models.acteur import ActeurStatus, DisplayedActeur -from qfdmo.views.adresses import AddressesView +from qfdmo.views.adresses import CarteView from unit_tests.core.test_utils import query_dict_from from unit_tests.qfdmo.acteur_factory import ( DisplayedActeurFactory, @@ -92,7 +92,7 @@ def displayed_acteur_reparacteur(displayed_acteur_reparer): @pytest.fixture def adresses_view(): - adresses_view = AddressesView() + adresses_view = CarteView() return adresses_view @@ -353,7 +353,7 @@ def test_sous_categorie_filter_by_action_no_match( displayed_acteur_donner_sscat_preter_sscat2, ): request = HttpRequest() - adresses_view = AddressesView() + adresses_view = CarteView() sous_categorie_id = sous_categorie.id request.GET = query_dict_from( { @@ -376,7 +376,7 @@ def test_sous_categorie_filter_by_action_1_match( displayed_acteur_donner_sscat_preter_sscat2, ): request = HttpRequest() - adresses_view = AddressesView() + adresses_view = CarteView() sous_categorie_id = sous_categorie2.id request.GET = query_dict_from( { diff --git a/jinja2/layout/turbo.html b/jinja2/layout/turbo.html new file mode 100644 index 000000000..2aeee0717 --- /dev/null +++ b/jinja2/layout/turbo.html @@ -0,0 +1,2 @@ +{% block content %} +{% endblock content %} diff --git a/jinja2/qfdmo/_addresses_partials/carte_result.html b/jinja2/qfdmo/_addresses_partials/carte_result.html deleted file mode 100644 index 6319a1811..000000000 --- a/jinja2/qfdmo/_addresses_partials/carte_result.html +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "qfdmo/_addresses_partials/result.html" %} - -{% block panel_extra_classes %}qfdmo-flex-grow{% endblock panel_extra_classes %} -{% block panel_header %}{% endblock panel_header %} \ No newline at end of file diff --git a/jinja2/qfdmo/adresse/detail.html b/jinja2/qfdmo/acteur/detail.html similarity index 100% rename from jinja2/qfdmo/adresse/detail.html rename to jinja2/qfdmo/acteur/detail.html diff --git a/jinja2/qfdmo/adresse_detail.html b/jinja2/qfdmo/adresse_detail.html index 3c32afcfc..b23da2b59 100644 --- a/jinja2/qfdmo/adresse_detail.html +++ b/jinja2/qfdmo/adresse_detail.html @@ -4,8 +4,8 @@
- {% include 'qfdmo/adresse/detail.html' %} + {% include 'qfdmo/acteur/detail.html' %}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/jinja2/qfdmo/adresses.html b/jinja2/qfdmo/adresses.html deleted file mode 100644 index 059d570af..000000000 --- a/jinja2/qfdmo/adresses.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends 'layout/base.html' %} - -{% block content %} - - {# Controleur général de gestion de la navigation et du formulaire #} - - -
- {% include "qfdmo/partials/featureflip_inputs.html" %} - {% if is_carte(request) %} - {# Panel Header #} - {% include 'qfdmo/_addresses_partials/carte_header.html' %} - {# Panel Result #} - {% include 'qfdmo/_addresses_partials/carte_result.html' %} - {# Panel «Filtres» #} - {% include 'qfdmo/_addresses_partials/filters/carte_filters.html' %} - {# Panel «Legend» #} - {% include 'qfdmo/_addresses_partials/filters/carte_legend.html' %} - {# Panel À propos #} - {% include 'qfdmo/_addresses_partials/filters/carte_apropos.html' %} - {{ form.epci_codes }} - {% else %} - {# Ici on on a tout préfixé de iframe, mais en fait il aurait fallu préfixer de formulaire. Car la carte peut être dans une iframe, non ? #} - {# Panel «Filtres avancés» #} - {% include 'qfdmo/_addresses_partials/filters/iframe_advanced_filters.html' %} - {# Panel «Modifier ma recherche» #} - {% include 'qfdmo/_addresses_partials/iframe_back_to_form.html' %} - {# Panel «Formulaire de recherche» #} - {% include 'qfdmo/_addresses_partials/iframe_form.html' %} - {# Panel «Résultats de la recherche» #} - {% include 'qfdmo/_addresses_partials/result.html' %} - {# Liens de pieds de page pour iframe #} - {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} - {% endif %} - -
-
- - {% include 'qfdmo/reparacteur_modale.html' %} -{% endblock %} diff --git a/jinja2/qfdmo/_addresses_partials/filters/carte_apropos.html b/jinja2/qfdmo/carte/_a_propos.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/filters/carte_apropos.html rename to jinja2/qfdmo/carte/_a_propos.html diff --git a/jinja2/qfdmo/_addresses_partials/filters/carte_filters.html b/jinja2/qfdmo/carte/_filters.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/filters/carte_filters.html rename to jinja2/qfdmo/carte/_filters.html diff --git a/jinja2/qfdmo/_addresses_partials/carte_header.html b/jinja2/qfdmo/carte/_header.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/carte_header.html rename to jinja2/qfdmo/carte/_header.html diff --git a/jinja2/qfdmo/_addresses_partials/filters/carte_legend.html b/jinja2/qfdmo/carte/_legend.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/filters/carte_legend.html rename to jinja2/qfdmo/carte/_legend.html diff --git a/jinja2/qfdmo/_addresses_partials/map_and_detail.html b/jinja2/qfdmo/carte/_map.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/map_and_detail.html rename to jinja2/qfdmo/carte/_map.html diff --git a/jinja2/qfdmo/carte/_result.html b/jinja2/qfdmo/carte/_result.html new file mode 100644 index 000000000..59c866ec4 --- /dev/null +++ b/jinja2/qfdmo/carte/_result.html @@ -0,0 +1,4 @@ +{% extends "qfdmo/carte/result.html" %} + +{% block panel_extra_classes %}qfdmo-flex-grow{% endblock panel_extra_classes %} +{% block panel_header %}{% endblock panel_header %} diff --git a/jinja2/qfdmo/carte/base.html b/jinja2/qfdmo/carte/base.html new file mode 100644 index 000000000..9e2ba6da8 --- /dev/null +++ b/jinja2/qfdmo/carte/base.html @@ -0,0 +1,51 @@ +{% extends base_template %} + + {% block content %} + + {# Controleur général de gestion de la navigation et du formulaire #} + +
+ {% include "qfdmo/partials/featureflip_inputs.html" %} + + {# Panel Header #} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/_header.html' %} + + {# Panel Result #} + {% include 'qfdmo/carte/_result.html' %} + + {# Panel «Filtres» #} + {% include 'qfdmo/carte/_filters.html' %} + + {# Panel «Legend» #} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/_legend.html' %} + + {# Panel À propos #} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/_a_propos.html' %} + + {{ form.epci_codes }} +
+
+ + {% include 'qfdmo/reparacteur_modale.html' %} + {% endblock %} diff --git a/jinja2/qfdmo/_addresses_partials/result.html b/jinja2/qfdmo/carte/result.html similarity index 95% rename from jinja2/qfdmo/_addresses_partials/result.html rename to jinja2/qfdmo/carte/result.html index c6009a927..73a5b936b 100644 --- a/jinja2/qfdmo/_addresses_partials/result.html +++ b/jinja2/qfdmo/carte/result.html @@ -25,6 +25,6 @@

{% endblock panel_header %} - {% include 'qfdmo/_addresses_partials/map_and_detail.html' %} + {% include 'qfdmo/carte/_map.html' %} diff --git a/jinja2/qfdmo/formulaire.html b/jinja2/qfdmo/formulaire.html new file mode 100644 index 000000000..becfe3da0 --- /dev/null +++ b/jinja2/qfdmo/formulaire.html @@ -0,0 +1,41 @@ +{% extends 'layout/base.html' %} + + {% block content %} + + {# Controleur général de gestion de la navigation et du formulaire #} + +
+ {% include "qfdmo/partials/featureflip_inputs.html" %} + {# Ici on on a tout préfixé de iframe, mais en fait il aurait fallu préfixer de formulaire. Car la carte peut être dans une iframe, non ? #} + {# Panel «Filtres avancés» #} + {% include 'qfdmo/_addresses_partials/filters/iframe_advanced_filters.html' %} + {# Panel «Modifier ma recherche» #} + {% include 'qfdmo/_addresses_partials/iframe_back_to_form.html' %} + {# Panel «Formulaire de recherche» #} + {% include 'qfdmo/_addresses_partials/iframe_form.html' %} + {# Panel «Résultats de la recherche» #} + {% include 'qfdmo/_addresses_partials/result.html' %} + {# Liens de pieds de page pour iframe #} + {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} +
+
+ + {% include 'qfdmo/reparacteur_modale.html' %} + {% endblock %} diff --git a/qfdmo/forms.py b/qfdmo/forms.py index a964e524d..a5e35ebbb 100644 --- a/qfdmo/forms.py +++ b/qfdmo/forms.py @@ -232,7 +232,7 @@ def load_choices(self, request: HttpRequest, **kwargs) -> None: ) -class IframeAddressesForm(AddressesForm): +class FormulaireForm(AddressesForm): def load_choices(self, request: HttpRequest, **kwargs) -> None: # The kwargs in function signature prevents type error. # TODO : refacto forms : if AddressesForm and CarteAddressesForm @@ -260,7 +260,7 @@ def load_choices(self, request: HttpRequest, **kwargs) -> None: ) -class CarteAddressesForm(AddressesForm): +class CarteForm(AddressesForm): def load_choices( self, request: HttpRequest, diff --git a/qfdmo/urls.py b/qfdmo/urls.py index ded03aea1..850118c63 100644 --- a/qfdmo/urls.py +++ b/qfdmo/urls.py @@ -5,7 +5,7 @@ from django.views.generic.base import RedirectView from qfdmo.views.adresses import ( - AddressesView, + CarteView, adresse_detail, get_object_list, getorcreate_revisionacteur, @@ -15,7 +15,7 @@ from qfdmo.views.dags import DagsValidation urlpatterns = [ - path("", AddressesView.as_view(), name="reemploi_solution"), + path("", CarteView.as_view(), name="reemploi_solution"), path("connexion", LoginView.as_view(), name="login"), path( "donnez-votre-avis", diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index 3eb032066..b12fc0301 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -19,7 +19,7 @@ from django.views.generic.edit import FormView from core.utils import get_direction -from qfdmo.forms import CarteAddressesForm, IframeAddressesForm +from qfdmo.forms import CarteForm, FormulaireForm from qfdmo.geo_api import bbox_from_list_of_geojson, retrieve_epci_geojson from qfdmo.leaflet import ( center_from_leaflet_bbox, @@ -47,8 +47,24 @@ BAN_API_URL = "https://api-adresse.data.gouv.fr/search/?q={}" -class AddressesView(FormView): - template_name = "qfdmo/adresses.html" +class TurboFormView(FormView): + def setup(self, request, *args, **kwargs): + super().setup(request, *args, **kwargs) + self.turbo = request.headers.get("Turbo-Frame") + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + if self.turbo: + context.update(turbo=self.turbo) + context.update(base_template="layout/turbo.html") + else: + context.update(base_template="layout/base.html") + + return context + + +class CarteView(TurboFormView, FormView): + template_name = "qfdmo/carte/base.html" def get_initial(self): initial = super().get_initial() @@ -104,11 +120,11 @@ 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 = CarteAddressesForm + self.form_class = CarteForm else: - self.form_class = IframeAddressesForm + self.form_class = FormulaireForm + self.template_name = "qfdmo/formulaire.html" def get_form(self, form_class=None): if self.request.GET & self.get_form_class().base_fields.keys(): diff --git a/unit_tests/qfdmo/test_addresses_view.py b/unit_tests/qfdmo/test_addresses_view.py index 6b9c6b3d5..b479681ff 100644 --- a/unit_tests/qfdmo/test_addresses_view.py +++ b/unit_tests/qfdmo/test_addresses_view.py @@ -1,7 +1,7 @@ import pytest from django.http import HttpRequest -from qfdmo.views.adresses import AddressesView +from qfdmo.views.adresses import CarteView class TestAdessesViewGetActionList: @@ -54,7 +54,7 @@ class TestAdessesViewGetActionList: def test_get_action_list(self, params, action_list): request = HttpRequest() request.GET = params - adresses_view = AddressesView() + adresses_view = CarteView() adresses_view.setup(request) assert [ From f320a4e2553ec74fcf51ba441afc6f75d9cc5546 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 22 Oct 2024 13:24:06 +0200 Subject: [PATCH 002/109] wip --- jinja2/qfdmo/carte/_map.html | 6 +++--- qfdmo/views/adresses.py | 1 + static/to_compile/src/map_controller.ts | 7 ++++--- static/to_compile/src/search_solution_form_controller.ts | 4 +++- static/to_compile/src/solution_map.ts | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/jinja2/qfdmo/carte/_map.html b/jinja2/qfdmo/carte/_map.html index 30b7456d4..33b6f9d4d 100644 --- a/jinja2/qfdmo/carte/_map.html +++ b/jinja2/qfdmo/carte/_map.html @@ -9,9 +9,9 @@ {# TODO: REFACTO OVERFLOW : supprimer les overflow auto et le padding left sur la liste qui empêche l'outline de déborder du conteneur #}
{% for adresse in acteurs.all() %} -
{ this.searchInZoneButtonTarget.classList.add("qfdmo-hidden") } - displayActorDetail(identifiantUnique: string) { + #displayActeur(identifiantUnique: string) { + // TODO: react on hash change this.dispatch("displayDetails", { detail: {} }) this.dispatch("setSrcDetailsAddress", { detail: { identifiantUnique: identifiantUnique }, diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index 4ba6be97f..0f7d92687 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -249,7 +249,8 @@ export default class extends Controller { this.detailsAddressPanelTarget.classList.remove("sm:qfdmo-w-[480]") } - displayActeurDetails(event) { + displayDigitalActeur(event) { + // TODO: refactor const identifiantUnique = event.currentTarget.dataset.identifiantUnique document .querySelector("[aria-controls='detailsAddressPanel'][aria-expanded='true']") @@ -260,6 +261,7 @@ export default class extends Controller { this.displayDetails() } setSrcDetailsAddress({ detail: { identifiantUnique } }) { + // TODO: refactor const latitude = this.latitudeInputTarget.value const longitude = this.longitudeInputTarget.value diff --git a/static/to_compile/src/solution_map.ts b/static/to_compile/src/solution_map.ts index bb2ace622..3c5be5396 100644 --- a/static/to_compile/src/solution_map.ts +++ b/static/to_compile/src/solution_map.ts @@ -132,7 +132,7 @@ export class SolutionMap { return htmlTree.join("") } - displayActor(actors: Array, bboxValue?: Array): void { + addActorMarkersToMap(actors: Array, bboxValue?: Array): void { let points: Array> = [] actors.forEach(function (actor: DisplayedActeur) { if (actor.location) { @@ -191,7 +191,7 @@ export class SolutionMap { #onClickMarker(event: L.LeafletEvent) { clearActivePinpoints() event.target._icon.classList.add(ACTIVE_PINPOINT_CLASSNAME) - this.#controller.displayActorDetail(event.target._identifiant_unique) + window.location.hash = event.target._identifiant_unique } #manageZoomControl() { From e048df678cf6ce49c7a35d1b170b3e597b31f038 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 22 Oct 2024 14:50:15 +0200 Subject: [PATCH 003/109] wip --- static/to_compile/src/map_controller.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/to_compile/src/map_controller.ts b/static/to_compile/src/map_controller.ts index 822b9fe93..372e15e83 100644 --- a/static/to_compile/src/map_controller.ts +++ b/static/to_compile/src/map_controller.ts @@ -54,6 +54,8 @@ export default class extends Controller { } actorsMap.initEventListener() + + window.addEventListener("hashchange", this.setActiveActor.bind(this)) } initialize() { @@ -73,7 +75,15 @@ export default class extends Controller { this.searchInZoneButtonTarget.classList.add("qfdmo-hidden") } - #displayActeur(identifiantUnique: string) { + setActiveActor(event?: HashChangeEvent) { + const identifiantUnique = event + ? new URL(event.newURL).hash.substring(1) + : window.location.hash.substring(1) + + if (!identifiantUnique) { + // TODO: gérer le cas où on a plus de hash dans l'URL + } + // TODO: react on hash change this.dispatch("displayDetails", { detail: {} }) this.dispatch("setSrcDetailsAddress", { From 71660b7f90b4e20aaf4036530e7cd26f2496ef51 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 23 Oct 2024 18:14:20 +0200 Subject: [PATCH 004/109] WIP --- jinja2/qfdmo/{carte/base.html => carte.html} | 0 jinja2/qfdmo/formulaire.html | 8 ++++---- .../_back_to_form.html} | 0 .../_filters.html} | 0 .../iframe_form.html => formulaire/_iframe_form.html} | 0 qfdmo/views/adresses.py | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename jinja2/qfdmo/{carte/base.html => carte.html} (100%) rename jinja2/qfdmo/{_addresses_partials/iframe_back_to_form.html => formulaire/_back_to_form.html} (100%) rename jinja2/qfdmo/{_addresses_partials/filters/iframe_advanced_filters.html => formulaire/_filters.html} (100%) rename jinja2/qfdmo/{_addresses_partials/iframe_form.html => formulaire/_iframe_form.html} (100%) diff --git a/jinja2/qfdmo/carte/base.html b/jinja2/qfdmo/carte.html similarity index 100% rename from jinja2/qfdmo/carte/base.html rename to jinja2/qfdmo/carte.html diff --git a/jinja2/qfdmo/formulaire.html b/jinja2/qfdmo/formulaire.html index becfe3da0..24f20800a 100644 --- a/jinja2/qfdmo/formulaire.html +++ b/jinja2/qfdmo/formulaire.html @@ -25,13 +25,13 @@ {% include "qfdmo/partials/featureflip_inputs.html" %} {# Ici on on a tout préfixé de iframe, mais en fait il aurait fallu préfixer de formulaire. Car la carte peut être dans une iframe, non ? #} {# Panel «Filtres avancés» #} - {% include 'qfdmo/_addresses_partials/filters/iframe_advanced_filters.html' %} + {% include 'qfdmo/formulaire/_filters.html' %} {# Panel «Modifier ma recherche» #} - {% include 'qfdmo/_addresses_partials/iframe_back_to_form.html' %} + {% include 'qfdmo/formulaire/_back_to_form.html' %} {# Panel «Formulaire de recherche» #} - {% include 'qfdmo/_addresses_partials/iframe_form.html' %} + {% include 'qfdmo/formulaire/_iframe_form.html' %} {# Panel «Résultats de la recherche» #} - {% include 'qfdmo/_addresses_partials/result.html' %} + {% include 'qfdmo/carte/_result.html' %} {# Liens de pieds de page pour iframe #} {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} diff --git a/jinja2/qfdmo/_addresses_partials/iframe_back_to_form.html b/jinja2/qfdmo/formulaire/_back_to_form.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/iframe_back_to_form.html rename to jinja2/qfdmo/formulaire/_back_to_form.html diff --git a/jinja2/qfdmo/_addresses_partials/filters/iframe_advanced_filters.html b/jinja2/qfdmo/formulaire/_filters.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/filters/iframe_advanced_filters.html rename to jinja2/qfdmo/formulaire/_filters.html diff --git a/jinja2/qfdmo/_addresses_partials/iframe_form.html b/jinja2/qfdmo/formulaire/_iframe_form.html similarity index 100% rename from jinja2/qfdmo/_addresses_partials/iframe_form.html rename to jinja2/qfdmo/formulaire/_iframe_form.html diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index 5686ce00b..6b8b9aecf 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -64,7 +64,7 @@ def get_context_data(self, **kwargs): class CarteView(TurboFormView, FormView): - template_name = "qfdmo/carte/base.html" + template_name = "qfdmo/carte.html" def get_initial(self): initial = super().get_initial() From fe5c9d8c8849103ee5e56f173641a2deb425c5b5 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 23 Oct 2024 18:28:10 +0200 Subject: [PATCH 005/109] reorganize folders --- jinja2/qfdmo/carte.html | 3 +- jinja2/qfdmo/carte/_detail.html | 50 +++++++++++ jinja2/qfdmo/carte/_digital_results.html | 37 ++++++++ .../{_legend.html => _legend_mobile.html} | 2 +- jinja2/qfdmo/carte/_map.html | 89 +------------------ jinja2/qfdmo/carte/_result.html | 3 +- .../_iframe.html | 0 .../advanced.html | 2 +- .../base.html | 0 jinja2/qfdmo/formulaire.html | 2 +- .../result.html => shared/_result.html} | 0 qfdmo/views/configurator.py | 4 +- 12 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 jinja2/qfdmo/carte/_detail.html create mode 100644 jinja2/qfdmo/carte/_digital_results.html rename jinja2/qfdmo/carte/{_legend.html => _legend_mobile.html} (97%) rename jinja2/qfdmo/{iframe_configurator => configurator}/_iframe.html (100%) rename jinja2/qfdmo/{iframe_configurator => configurator}/advanced.html (98%) rename jinja2/qfdmo/{iframe_configurator => configurator}/base.html (100%) rename jinja2/qfdmo/{carte/result.html => shared/_result.html} (100%) diff --git a/jinja2/qfdmo/carte.html b/jinja2/qfdmo/carte.html index 9e2ba6da8..a3b2f77c3 100644 --- a/jinja2/qfdmo/carte.html +++ b/jinja2/qfdmo/carte.html @@ -37,9 +37,10 @@ {# Panel «Legend» #} {# TODO: refacto turbo, should be moved outside of form #} - {% include 'qfdmo/carte/_legend.html' %} + {% include 'qfdmo/carte/_legend_mobile.html' %} {# Panel À propos #} + {# TODO: refacto turbo, should be moved outside of form #} {% include 'qfdmo/carte/_a_propos.html' %} diff --git a/jinja2/qfdmo/carte/_detail.html b/jinja2/qfdmo/carte/_detail.html new file mode 100644 index 000000000..de55d1921 --- /dev/null +++ b/jinja2/qfdmo/carte/_detail.html @@ -0,0 +1,50 @@ +{# Détail de l'adresse #} +
+
+
+ + + +
+ {# passer la direction en paramètre #} +
+
+ {% with direction=form.direction.value(), latitude=form.latitude.value(), longitude=form.longitude.value() %} + + + {% endwith %} +
+
+
+
diff --git a/jinja2/qfdmo/carte/_digital_results.html b/jinja2/qfdmo/carte/_digital_results.html new file mode 100644 index 000000000..9435a4808 --- /dev/null +++ b/jinja2/qfdmo/carte/_digital_results.html @@ -0,0 +1,37 @@ +{# On line addresses #} +
+ {# TODO: REFACTO OVERFLOW : supprimer les overflow auto et le padding left sur la liste qui empêche l'outline de déborder du conteneur #} +
+ {% for adresse in acteurs.all() %} + + {% endfor %} + {% if acteurs.count() == 0 %} +

+ Aucune solution en ligne n'a été trouvée pour votre recherche. +

+ {% endif %} +
+
+
+
diff --git a/jinja2/qfdmo/carte/_legend.html b/jinja2/qfdmo/carte/_legend_mobile.html similarity index 97% rename from jinja2/qfdmo/carte/_legend.html rename to jinja2/qfdmo/carte/_legend_mobile.html index 8781cdf0e..ef196f7eb 100644 --- a/jinja2/qfdmo/carte/_legend.html +++ b/jinja2/qfdmo/carte/_legend_mobile.html @@ -1,4 +1,4 @@ -{# Panel «Légende» #} +{# Panel «Légende» affiché uniquement en mobile #}
diff --git a/jinja2/qfdmo/carte/_map.html b/jinja2/qfdmo/carte/_map.html index bd517b60c..e31683dec 100644 --- a/jinja2/qfdmo/carte/_map.html +++ b/jinja2/qfdmo/carte/_map.html @@ -4,43 +4,7 @@
{% if request.GET["digital"] == "1" %} - {# On line addresses#} -
- {# TODO: REFACTO OVERFLOW : supprimer les overflow auto et le padding left sur la liste qui empêche l'outline de déborder du conteneur #} -
- {% for adresse in acteurs.all() %} - - {% endfor %} - {% if acteurs.count() == 0 %} -

- Aucune solution en ligne n'a été trouvée pour votre recherche. -

- {% endif %} -
-
-
-
+ {% include "qfdmo/carte/_digital_results" %} {% else %} {# Near by addresses#}
-
-
- - - -
- {# passer la direction en paramètre #} -
-
- {% with direction=form.direction.value(), latitude=form.latitude.value(), longitude=form.longitude.value() %} - - - {% endwith %} -
-
-
-
+ {% include "qfdmo/carte/_detail.html" %}
diff --git a/jinja2/qfdmo/carte/_result.html b/jinja2/qfdmo/carte/_result.html index 59c866ec4..c4702596d 100644 --- a/jinja2/qfdmo/carte/_result.html +++ b/jinja2/qfdmo/carte/_result.html @@ -1,4 +1,3 @@ -{% extends "qfdmo/carte/result.html" %} +{% extends "qfdmo/shared/_result.html" %} -{% block panel_extra_classes %}qfdmo-flex-grow{% endblock panel_extra_classes %} {% block panel_header %}{% endblock panel_header %} diff --git a/jinja2/qfdmo/iframe_configurator/_iframe.html b/jinja2/qfdmo/configurator/_iframe.html similarity index 100% rename from jinja2/qfdmo/iframe_configurator/_iframe.html rename to jinja2/qfdmo/configurator/_iframe.html diff --git a/jinja2/qfdmo/iframe_configurator/advanced.html b/jinja2/qfdmo/configurator/advanced.html similarity index 98% rename from jinja2/qfdmo/iframe_configurator/advanced.html rename to jinja2/qfdmo/configurator/advanced.html index c7cfbe54e..11a5fd3be 100644 --- a/jinja2/qfdmo/iframe_configurator/advanced.html +++ b/jinja2/qfdmo/configurator/advanced.html @@ -109,6 +109,6 @@

Configurateur d'Iframe

- {% include "qfdmo/iframe_configurator/_iframe.html"%} + {% include "qfdmo/configurator/_iframe.html"%}
{% endblock content %} diff --git a/jinja2/qfdmo/iframe_configurator/base.html b/jinja2/qfdmo/configurator/base.html similarity index 100% rename from jinja2/qfdmo/iframe_configurator/base.html rename to jinja2/qfdmo/configurator/base.html diff --git a/jinja2/qfdmo/formulaire.html b/jinja2/qfdmo/formulaire.html index 24f20800a..7106a7f45 100644 --- a/jinja2/qfdmo/formulaire.html +++ b/jinja2/qfdmo/formulaire.html @@ -31,7 +31,7 @@ {# Panel «Formulaire de recherche» #} {% include 'qfdmo/formulaire/_iframe_form.html' %} {# Panel «Résultats de la recherche» #} - {% include 'qfdmo/carte/_result.html' %} + {% include 'qfdmo/shared/_result.html' %} {# Liens de pieds de page pour iframe #} {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} diff --git a/jinja2/qfdmo/carte/result.html b/jinja2/qfdmo/shared/_result.html similarity index 100% rename from jinja2/qfdmo/carte/result.html rename to jinja2/qfdmo/shared/_result.html diff --git a/qfdmo/views/configurator.py b/qfdmo/views/configurator.py index d60672758..8d8229fa1 100644 --- a/qfdmo/views/configurator.py +++ b/qfdmo/views/configurator.py @@ -14,7 +14,7 @@ class ConfiguratorView(FormView): form_class = ConfiguratorForm - template_name = "qfdmo/iframe_configurator/base.html" + template_name = "qfdmo/configurator/base.html" def form_valid(self, form) -> HttpResponse: return render( @@ -51,7 +51,7 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]: class AdvancedConfiguratorView(LoginRequiredMixin, FormView): form_class = AdvancedConfiguratorForm - template_name = "qfdmo/iframe_configurator/advanced.html" + template_name = "qfdmo/configurator/advanced.html" def get_initial(self): initial = super().get_initial() From ecffdf0ee0829330af7e711f87384ae80b50edb4 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 23 Oct 2024 21:06:14 +0200 Subject: [PATCH 006/109] reorganize folders --- jinja2/qfdmo/acteur/{detail.html => _detail.html} | 0 jinja2/qfdmo/adresse_detail.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename jinja2/qfdmo/acteur/{detail.html => _detail.html} (100%) diff --git a/jinja2/qfdmo/acteur/detail.html b/jinja2/qfdmo/acteur/_detail.html similarity index 100% rename from jinja2/qfdmo/acteur/detail.html rename to jinja2/qfdmo/acteur/_detail.html diff --git a/jinja2/qfdmo/adresse_detail.html b/jinja2/qfdmo/adresse_detail.html index b23da2b59..36a81defd 100644 --- a/jinja2/qfdmo/adresse_detail.html +++ b/jinja2/qfdmo/adresse_detail.html @@ -4,7 +4,7 @@
- {% include 'qfdmo/acteur/detail.html' %} + {% include 'qfdmo/acteur/_detail.html' %}
From 52c2d86c055e6d2b272f74915c16ce4007889ded Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 23 Oct 2024 21:54:20 +0200 Subject: [PATCH 007/109] reorganize folders --- jinja2/qfdmo/acteur/_detail.html | 5 ++++- jinja2/qfdmo/adresse_detail.html | 11 ----------- jinja2/qfdmo/carte.html | 22 +++++----------------- jinja2/qfdmo/carte/_detail.html | 8 +++----- jinja2/qfdmo/formulaire.html | 29 +++++++++++------------------ qfdmo/models/acteur.py | 2 +- qfdmo/urls.py | 3 ++- qfdmo/views/adresses.py | 2 +- 8 files changed, 27 insertions(+), 55 deletions(-) delete mode 100644 jinja2/qfdmo/adresse_detail.html diff --git a/jinja2/qfdmo/acteur/_detail.html b/jinja2/qfdmo/acteur/_detail.html index 6b49d117c..77e2b4290 100644 --- a/jinja2/qfdmo/acteur/_detail.html +++ b/jinja2/qfdmo/acteur/_detail.html @@ -1,6 +1,9 @@ +{# Acteur detail view content #} {% if adresse.labels.filter(afficher=True, bonus=True, type_enseigne=False) %} -

Éligible au bonus réparation

+

+ Éligible au bonus réparation +

{% elif adresse.labels.filter(afficher=True, type_enseigne=False).count() == 1 %} {% with source_or_label=adresse.labels.filter(afficher=True, type_enseigne=False).first() %} {% if source_or_label.logo_file %} diff --git a/jinja2/qfdmo/adresse_detail.html b/jinja2/qfdmo/adresse_detail.html deleted file mode 100644 index 36a81defd..000000000 --- a/jinja2/qfdmo/adresse_detail.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'layout/base.html' %} - -{% block content %} -
-
- - {% include 'qfdmo/acteur/_detail.html' %} - -
-
-{% endblock %} diff --git a/jinja2/qfdmo/carte.html b/jinja2/qfdmo/carte.html index a3b2f77c3..d82ddca07 100644 --- a/jinja2/qfdmo/carte.html +++ b/jinja2/qfdmo/carte.html @@ -5,23 +5,11 @@ {# Controleur général de gestion de la navigation et du formulaire #}
{% include "qfdmo/partials/featureflip_inputs.html" %} diff --git a/jinja2/qfdmo/carte/_detail.html b/jinja2/qfdmo/carte/_detail.html index de55d1921..2baceabfc 100644 --- a/jinja2/qfdmo/carte/_detail.html +++ b/jinja2/qfdmo/carte/_detail.html @@ -36,11 +36,9 @@
{% with direction=form.direction.value(), latitude=form.latitude.value(), longitude=form.longitude.value() %} - {% endwith %} diff --git a/jinja2/qfdmo/formulaire.html b/jinja2/qfdmo/formulaire.html index 7106a7f45..55ea739bd 100644 --- a/jinja2/qfdmo/formulaire.html +++ b/jinja2/qfdmo/formulaire.html @@ -4,34 +4,27 @@ {# Controleur général de gestion de la navigation et du formulaire #} - {% include "qfdmo/partials/featureflip_inputs.html" %} - {# Ici on on a tout préfixé de iframe, mais en fait il aurait fallu préfixer de formulaire. Car la carte peut être dans une iframe, non ? #} + {# Panel «Filtres avancés» #} {% include 'qfdmo/formulaire/_filters.html' %} + {# Panel «Modifier ma recherche» #} {% include 'qfdmo/formulaire/_back_to_form.html' %} + {# Panel «Formulaire de recherche» #} {% include 'qfdmo/formulaire/_iframe_form.html' %} + {# Panel «Résultats de la recherche» #} {% include 'qfdmo/shared/_result.html' %} + {# Liens de pieds de page pour iframe #} {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index cb398ea5d..49f9f8713 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -315,7 +315,7 @@ def get_share_url(self, request: HttpRequest, direction: str | None = None) -> s protocol = "https" if request.is_secure() else "http" host = request.get_host() base_url = f"{protocol}://{host}" - base_url += reverse("qfdmo:adresse_detail", args=[self.identifiant_unique]) + base_url += reverse("qfdmo:acteur-detail", args=[self.identifiant_unique]) params = [] if "carte" in request.GET: diff --git a/qfdmo/urls.py b/qfdmo/urls.py index 850118c63..9dfde3468 100644 --- a/qfdmo/urls.py +++ b/qfdmo/urls.py @@ -62,8 +62,9 @@ ), path( "adresse/", + # ActeurView.as_view(), adresse_detail, - name="adresse_detail", + name="acteur-detail", ), path( "solution_admin/", diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index 6b8b9aecf..19a671d3e 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -605,7 +605,7 @@ def adresse_detail(request, identifiant_unique): return render( request, - "qfdmo/adresse_detail.html", + "qfdmo/acteur.html", { "adresse": displayed_acteur, "latitude": latitude, From 7e58652dc293ffc0e1382da1ca9c768bbe4a0e9f Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 23 Oct 2024 21:54:57 +0200 Subject: [PATCH 008/109] reorganize folders --- jinja2/qfdmo/carte.html | 2 +- jinja2/qfdmo/formulaire.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jinja2/qfdmo/carte.html b/jinja2/qfdmo/carte.html index d82ddca07..d10f5612e 100644 --- a/jinja2/qfdmo/carte.html +++ b/jinja2/qfdmo/carte.html @@ -5,7 +5,7 @@ {# Controleur général de gestion de la navigation et du formulaire #}

- {% for acteur_service in adresse.get_acteur_services() %} + {% for acteur_service in adresse.acteur_services_libelles_alpha_sorted %} {{ acteur_service }}{% if not loop.last %}, {% endif %} {% endfor %} {{ distance_to_acteur(request, adresse) }} diff --git a/jinja2/qfdmo/acteur/tabs/about_panel.html b/jinja2/qfdmo/acteur/tabs/about_panel.html index 2ba28d52a..c0fe103d5 100644 --- a/jinja2/qfdmo/acteur/tabs/about_panel.html +++ b/jinja2/qfdmo/acteur/tabs/about_panel.html @@ -16,7 +16,7 @@ {% include "qfdmo/acteur/tabs/sections/description.html" %} {% endif %} - {% if False %} + {% if object.acteur_services_libelles_alpha_sorted %} {% include "qfdmo/acteur/tabs/sections/services_disponibles.html" %} {% endif %} diff --git a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html index 0a3696bfc..e86d7a718 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html +++ b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html @@ -5,4 +5,8 @@ {% endblock title %} {% block content %} +{% for service in object.sorted_proposition_services %} + {{ service.action }} + {{ service.sous_categories.all() }} +{% endfor %} {% endblock content %} diff --git a/jinja2/qfdmo/carte/_digital_results.html b/jinja2/qfdmo/carte/_digital_results.html index 8cbaeea42..28392103b 100644 --- a/jinja2/qfdmo/carte/_digital_results.html +++ b/jinja2/qfdmo/carte/_digital_results.html @@ -20,7 +20,7 @@ {% endwith %}

{{ adresse.libelle }}

- {% for acteur_service in adresse.get_acteur_services() %} + {% for acteur_service in adresse.acteur_services_libelles_alpha_sorted %} {{ acteur_service }}{% if not loop.last %}
{% endif %} {% endfor %}

diff --git a/qfdmo/admin/acteur.py b/qfdmo/admin/acteur.py index 2e9c2c428..71c483592 100644 --- a/qfdmo/admin/acteur.py +++ b/qfdmo/admin/acteur.py @@ -384,7 +384,7 @@ def get_form( acteur_value_js = str(acteur_value).replace("'", "\\'") if field_name == "acteur_services": - form_field.help_text = acteur.get_acteur_services() + form_field.help_text = acteur.acteur_services_libelles_alpha_sorted if acteur_value and ( isinstance(form_field, CharField) diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index 97260de5c..f4fc92cf0 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -14,7 +14,7 @@ from django.contrib.gis.geos.geometry import GEOSGeometry from django.core.cache import cache from django.core.files.images import get_image_dimensions -from django.db.models import Exists, Min, OuterRef +from django.db.models import Case, Exists, Min, OuterRef, Value, When from django.db.models.functions import Now from django.forms import ValidationError, model_to_dict from django.http import HttpRequest @@ -346,23 +346,37 @@ def libelle(self): def is_digital(self) -> bool: return self.acteur_type_id == ActeurType.get_digital_acteur_type_id() - def get_acteur_services(self) -> list[str]: - return sorted( - list( - set( - [ - acteur_service.libelle - for acteur_service in self.acteur_services.all() - if acteur_service.libelle - ] + @cached_property + def sorted_proposition_services(self): + proposition_services = self.proposition_services.all() + order = ["action__order"] + + if action_principale := self.action_principale: + proposition_services = proposition_services.annotate( + action_principale=Case( + When(action__id=action_principale.id, then=Value(0)), + default=Value(1), ) ) + order = ["action_principale", *order] + + return proposition_services.order_by(*order) + + logger.info(proposition_services) + return proposition_services + + @cached_property + def acteur_services_libelles_alpha_sorted(self) -> list[str]: + return list( + self.acteur_services.exclude(libelle=None) + .order_by("libelle") + .values_list("libelle", flat=True) + .distinct() ) @cached_property def acteur_services_display(self): - logger.info(self.get_acteur_services()) - return ",".join(self.get_acteur_services()) + return ", ".join(self.acteur_services_libelles_alpha_sorted) @cached_property def labels_display(self): diff --git a/unit_tests/qfdmo/test_acteur.py b/unit_tests/qfdmo/test_acteur.py index 8e0aada73..b333763cf 100644 --- a/unit_tests/qfdmo/test_acteur.py +++ b/unit_tests/qfdmo/test_acteur.py @@ -334,7 +334,9 @@ def test_acteur_actions_basic(self, displayed_acteur): ActeurServiceFactory(libelle="Par un professionnel") ) - assert displayed_acteur.get_acteur_services() == ["Par un professionnel"] + assert displayed_acteur.acteur_services_libelles_alpha_sorted == [ + "Par un professionnel" + ] def test_acteur_actions_multiple(self, displayed_acteur): displayed_acteur.acteur_services.add( From 62e04f55a364f939da4c8af5a1a22512730f82c2 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Mon, 28 Oct 2024 21:16:23 +0100 Subject: [PATCH 023/109] wip --- .../tabs/sections/services_disponibles.html | 18 ++++++++++++++---- qfdmo/models/acteur.py | 15 +++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html index e86d7a718..911a371b1 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html +++ b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html @@ -5,8 +5,18 @@ {% endblock title %} {% block content %} -{% for service in object.sorted_proposition_services %} - {{ service.action }} - {{ service.sous_categories.all() }} -{% endfor %} +
+ {% for service in object.sorted_proposition_services %} +
+ {% with action=service.action %} + {% with content=action.libelle,icon=action.icon,couleur=action.couleur %} + {% include "qfdmo/acteur/tabs/_tag.html" %} + {% endwith %} + {% endwith %} +

+ {{ service.sous_categories_display }} +

+
+ {% endfor %} +
{% endblock content %} diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index f4fc92cf0..735fe8041 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -348,7 +348,11 @@ def is_digital(self) -> bool: @cached_property def sorted_proposition_services(self): - proposition_services = self.proposition_services.all() + proposition_services = ( + self.proposition_services.all() + .prefetch_related("sous_categories") + .select_related("action") + ) order = ["action__order"] if action_principale := self.action_principale: @@ -362,9 +366,6 @@ def sorted_proposition_services(self): return proposition_services.order_by(*order) - logger.info(proposition_services) - return proposition_services - @cached_property def acteur_services_libelles_alpha_sorted(self) -> list[str]: return list( @@ -743,6 +744,12 @@ class Meta: SousCategorieObjet, ) + @cached_property + def sous_categories_display(self): + return ", ".join( + self.sous_categories.order_by("libelle").values_list("libelle", flat=True) + ) + def __str__(self): return f"{self.action.code}" From 4e3275e8b3a2ccfe32b5942c717c22b6e07d9374 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 29 Oct 2024 13:10:30 +0100 Subject: [PATCH 024/109] WIP --- .secrets.baseline | 4 +- core/settings.py | 1 + .../source_or_label_list.html | 17 --- jinja2/qfdmo/acteur.html | 9 +- jinja2/qfdmo/acteur/_action.html | 5 +- jinja2/qfdmo/acteur/_actions.html | 6 +- jinja2/qfdmo/acteur/_label.html | 15 +++ jinja2/qfdmo/acteur/_labels.html | 26 ++-- jinja2/qfdmo/acteur/_labels/bonus.html | 2 +- jinja2/qfdmo/acteur/tabs/_section.html | 2 +- jinja2/qfdmo/acteur/tabs/_tag.html | 12 ++ jinja2/qfdmo/acteur/tabs/about_panel.html | 2 +- jinja2/qfdmo/acteur/tabs/labels_panel.html | 6 +- jinja2/qfdmo/acteur/tabs/sections/bonus.html | 11 ++ .../tabs/sections/services_disponibles.html | 2 +- jinja2/qfdmo/acteur/tabs/sources_panel.html | 6 +- jinja2/qfdmo/shared/tag.html | 7 +- qfdmo/api.py | 4 +- qfdmo/migrations/0099_alter_action_couleur.py | 58 +++++++++ ...00_rename_couleur_action_couleur_foncee.py | 18 +++ .../migrations/0101_action_couleur_claire.py | 58 +++++++++ ...02_alter_action_couleur_claire_and_more.py | 122 ++++++++++++++++++ qfdmo/models/acteur.py | 9 +- qfdmo/models/action.py | 57 +++++++- requirements.in | 1 + requirements.txt | 8 +- tailwind.config.js | 2 + 27 files changed, 407 insertions(+), 63 deletions(-) delete mode 100644 jinja2/qfdmo/_address_card_partials/source_or_label_list.html create mode 100644 jinja2/qfdmo/acteur/_label.html create mode 100644 jinja2/qfdmo/acteur/tabs/_tag.html create mode 100644 qfdmo/migrations/0099_alter_action_couleur.py create mode 100644 qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py create mode 100644 qfdmo/migrations/0101_action_couleur_claire.py create mode 100644 qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py diff --git a/.secrets.baseline b/.secrets.baseline index c4b69f257..41697d1b7 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -151,7 +151,7 @@ "filename": "core/settings.py", "hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9", "is_verified": false, - "line_number": 203 + "line_number": 204 } ], "docker-compose.yml": [ @@ -207,5 +207,5 @@ } ] }, - "generated_at": "2024-10-24T13:39:34Z" + "generated_at": "2024-10-29T12:10:27Z" } diff --git a/core/settings.py b/core/settings.py index 636dde17e..29bcd6c97 100644 --- a/core/settings.py +++ b/core/settings.py @@ -50,6 +50,7 @@ "widget_tweaks", "dsfr", "django.forms", + "colorfield", "core", "qfdmd", "qfdmo", diff --git a/jinja2/qfdmo/_address_card_partials/source_or_label_list.html b/jinja2/qfdmo/_address_card_partials/source_or_label_list.html deleted file mode 100644 index 1e82d9d01..000000000 --- a/jinja2/qfdmo/_address_card_partials/source_or_label_list.html +++ /dev/null @@ -1,17 +0,0 @@ -{% for source_or_label in source_or_label_list %} - -{% endfor %} diff --git a/jinja2/qfdmo/acteur.html b/jinja2/qfdmo/acteur.html index a7898c1b7..53223b2f4 100644 --- a/jinja2/qfdmo/acteur.html +++ b/jinja2/qfdmo/acteur.html @@ -6,13 +6,16 @@
+ {% if object.labels_display %} + {% include "qfdmo/acteur/_labels.html" %} + {% endif %} +

{{ object.nom }}

-

+

{{ object.acteur_services_display }} {{ distance }}

- {% include "qfdmo/acteur/_labels.html" %} -
+ {% include "qfdmo/acteur/tabs/_separator.html" %} {% include "qfdmo/acteur/_actions.html" %}
{% include "qfdmo/acteur/_tabs.html" %} diff --git a/jinja2/qfdmo/acteur/_action.html b/jinja2/qfdmo/acteur/_action.html index c1c05bd42..5bb1a7af3 100644 --- a/jinja2/qfdmo/acteur/_action.html +++ b/jinja2/qfdmo/acteur/_action.html @@ -2,6 +2,7 @@ class=" qfdmo-flex qfdmo-flex-col qfdmo-items-center qfdmo-bg-none qfdmo-no-external-link-icon + qfdmo-space-y-1v " href="{% block href %}{{ url }}{% endblock href %}" title="{{ title }}" @@ -9,6 +10,6 @@ rel="noreferrer" {% block data_action %}data_action="click -> analytics#captureInteractionWithSolutionDetails"{% endblock data_action %} > - - {{ text }} + + {{ text }} diff --git a/jinja2/qfdmo/acteur/_actions.html b/jinja2/qfdmo/acteur/_actions.html index e9b77274a..6988344c2 100644 --- a/jinja2/qfdmo/acteur/_actions.html +++ b/jinja2/qfdmo/acteur/_actions.html @@ -1,4 +1,6 @@ -
+
{% if itineraire_url %} {% with text="Itinéraire",url=itineraire_url,icon="fr-icon-send-plane-line" %} {% include "qfdmo/acteur/_action.html" %} @@ -25,7 +27,7 @@ diff --git a/jinja2/qfdmo/acteur/_labels.html b/jinja2/qfdmo/acteur/_labels.html index 3a11f8900..32d38bcc1 100644 --- a/jinja2/qfdmo/acteur/_labels.html +++ b/jinja2/qfdmo/acteur/_labels.html @@ -1,13 +1,15 @@ -{% if object.labels_display|length > 1 %} - {% with content="Cet établissement dispose de plusieurs labels",icon="fr-icon-shield-check-line" %} - {% include "qfdmo/shared/tag.html" %} - {% endwith %} -{% endif %} - -{% for label in object.labels_display %} - {% if label.bonus %} - {% include "qfdmo/acteur/_labels/bonus.html" %} - {% else %} - {% include "qfdmo/acteur/_labels/generic.html" %} +
+ {% if object.labels_display|length > 1 %} + {% with content="Cet établissement dispose de plusieurs labels",icon="fr-icon-shield-check-line" %} + {% include "qfdmo/shared/tag.html" %} + {% endwith %} {% endif %} -{% endfor %} + + {% with label=object.labels_display.first() %} + {% if label.bonus %} + {% include "qfdmo/acteur/_labels/bonus.html" %} + {% else %} + {% include "qfdmo/acteur/_labels/generic.html" %} + {% endif %} + {% endwith %} +
diff --git a/jinja2/qfdmo/acteur/_labels/bonus.html b/jinja2/qfdmo/acteur/_labels/bonus.html index 3865a3014..c31b70369 100644 --- a/jinja2/qfdmo/acteur/_labels/bonus.html +++ b/jinja2/qfdmo/acteur/_labels/bonus.html @@ -1,3 +1,3 @@ -{% with content="Éligible au bonus réparation",icon="fr-icon-ancient-gate-fill" %} +{% with content="Éligible au bonus réparation",icon="fr-icon-percent-line",href="#bonus" %} {% include "qfdmo/shared/tag.html" %} {% endwith %} diff --git a/jinja2/qfdmo/acteur/tabs/_section.html b/jinja2/qfdmo/acteur/tabs/_section.html index 52beba68c..6a71a1fd2 100644 --- a/jinja2/qfdmo/acteur/tabs/_section.html +++ b/jinja2/qfdmo/acteur/tabs/_section.html @@ -1,4 +1,4 @@ -
+

{% block title %} {% endblock title %} diff --git a/jinja2/qfdmo/acteur/tabs/_tag.html b/jinja2/qfdmo/acteur/tabs/_tag.html new file mode 100644 index 000000000..be7d9e8b6 --- /dev/null +++ b/jinja2/qfdmo/acteur/tabs/_tag.html @@ -0,0 +1,12 @@ +

+ + {{ content }} + +

diff --git a/jinja2/qfdmo/acteur/tabs/about_panel.html b/jinja2/qfdmo/acteur/tabs/about_panel.html index c0fe103d5..6aa58881a 100644 --- a/jinja2/qfdmo/acteur/tabs/about_panel.html +++ b/jinja2/qfdmo/acteur/tabs/about_panel.html @@ -20,7 +20,7 @@ {% include "qfdmo/acteur/tabs/sections/services_disponibles.html" %} {% endif %} - {% if False %} + {% if object.is_bonus_reparation %} {% include "qfdmo/acteur/tabs/sections/bonus.html" %} {% endif %} diff --git a/jinja2/qfdmo/acteur/tabs/labels_panel.html b/jinja2/qfdmo/acteur/tabs/labels_panel.html index cd1ec6179..65f168987 100644 --- a/jinja2/qfdmo/acteur/tabs/labels_panel.html +++ b/jinja2/qfdmo/acteur/tabs/labels_panel.html @@ -5,7 +5,7 @@ {% block aria_labelledby %}labelsPanel{% endblock aria_labelledby %} {% block content %} - {% with source_or_label_list=object.labels.filter(afficher=True, type_enseigne=False) %} - {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} - {% endwith %} +{% for source_or_label in object.labels_display %} + {% include "qfdmo/acteur/_label.html" %} +{% endfor %} {% endblock content %} diff --git a/jinja2/qfdmo/acteur/tabs/sections/bonus.html b/jinja2/qfdmo/acteur/tabs/sections/bonus.html index 3e5925ed3..135b147cd 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/bonus.html +++ b/jinja2/qfdmo/acteur/tabs/sections/bonus.html @@ -1 +1,12 @@ {% extends "qfdmo/acteur/tabs/_section.html" %} + +{% block wrapper_attrs %}id="bonus"{% endblock wrapper_attrs %} + +{% block title %} +{# TODO : icone #} +Éligible au bonus réparation +{% endblock title %} + +{% block content %} +Découvrez les réparations pour lesquelles vous pouvez bénéficier d'une aide et faites des économies. +{% endblock content %} diff --git a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html index 911a371b1..6188461aa 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html +++ b/jinja2/qfdmo/acteur/tabs/sections/services_disponibles.html @@ -9,7 +9,7 @@ {% for service in object.sorted_proposition_services %}
{% with action=service.action %} - {% with content=action.libelle,icon=action.icon,couleur=action.couleur %} + {% with content=action.libelle,icon=action.icon,background=action.couleur_claire,border=action.couleur_foncee %} {% include "qfdmo/acteur/tabs/_tag.html" %} {% endwith %} {% endwith %} diff --git a/jinja2/qfdmo/acteur/tabs/sources_panel.html b/jinja2/qfdmo/acteur/tabs/sources_panel.html index 7387207bd..b4d9a9a02 100644 --- a/jinja2/qfdmo/acteur/tabs/sources_panel.html +++ b/jinja2/qfdmo/acteur/tabs/sources_panel.html @@ -5,7 +5,7 @@ {% block aria_labelledby %}sourcesPanel{% endblock aria_labelledby %} {% block content %} - {% with source_or_label_list=object.sources.all() %} - {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} - {% endwith %} +{% for source_or_label in object.sources.all() %} + {% include "qfdmo/acteur/_label.html" %} +{% endfor %} {% endblock content %} diff --git a/jinja2/qfdmo/shared/tag.html b/jinja2/qfdmo/shared/tag.html index 951ea182a..99148c58c 100644 --- a/jinja2/qfdmo/shared/tag.html +++ b/jinja2/qfdmo/shared/tag.html @@ -1,5 +1,8 @@ {# Migrate to django dsfr when jinja dropped #} -

+<{% if href %}a href="{{ href }}"{% else %}p{% endif %} + class="fr-tag fr-tag--sm fr-tag--icon-left {{ icon }}" + {% if id %}data-testid="{{ id }}"{% endif %} +> {% if icon_url %} {{ content }} -

+ diff --git a/qfdmo/api.py b/qfdmo/api.py index 953b78a97..76cbe5ea0 100644 --- a/qfdmo/api.py +++ b/qfdmo/api.py @@ -41,9 +41,11 @@ class Meta: class ActionSchema(ModelSchema): + couleur: str = Field(..., alias="couleur_foncee") + class Meta: model = Action - fields = ["id", "code", "libelle", "couleur"] + fields = ["id", "code", "libelle"] class ActeurServiceSchema(ModelSchema): diff --git a/qfdmo/migrations/0099_alter_action_couleur.py b/qfdmo/migrations/0099_alter_action_couleur.py new file mode 100644 index 000000000..9538a1af1 --- /dev/null +++ b/qfdmo/migrations/0099_alter_action_couleur.py @@ -0,0 +1,58 @@ +# Generated by Django 5.1.1 on 2024-10-29 11:15 + +import colorfield.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("qfdmo", "0098_alter_action_couleur_alter_groupeaction_couleur"), + ] + + operations = [ + migrations.AlterField( + model_name="action", + name="couleur", + field=colorfield.fields.ColorField( + blank=True, + choices=[ + ("#AEA397", "beige-gris-galet"), + ("#3558A2", "blue-cumulus-sun-368"), + ("#417DC4", "blue-cumulus"), + ("#bfccfb", "blue-ecume-850"), + ("#465F9D", "blue-ecume"), + ("#0055FF", "blue-france"), + ("#D1B781", "brown-cafe-creme-main-782"), + ("#D1B781", "brown-cafe-creme"), + ("#C08C65", "brown-caramel"), + ("#BD987A", "brown-opera"), + ("#009099", "green-archipel"), + ("#95e257", "green-bourgeon-850"), + ("#68A532", "green-bourgeon"), + ("#00A95F", "green-emeraude"), + ("#73e0cf", "green-menthe-850"), + ("#009081", "green-menthe-main-548"), + ("#37635f", "green-menthe-sun-373"), + ("#009081", "green-menthe"), + ("#B7A73F", "green-tilleul-verveine"), + ("#E4794A", "orange-terre-battue-main-645"), + ("#E4794A", "orange-terre-battue"), + ("#E18B76", "pink-macaron"), + ("#fcbfb7", "pink-tuile-850"), + ("#CE614A", "pink-tuile"), + ("#A558A0", "purple-glycine-main-494"), + ("#A558A0", "purple-glycine"), + ("#fcc63a", "yellow-moutarde-850"), + ("#C3992A", "yellow-moutarde"), + ("#e9c53b", "yellow-tournesol"), + ("#bb8568", "brown-caramel-sun-425-hover"), + ], + default="#C3992A", + image_field=None, + max_length=255, + null=True, + samples=None, + ), + ), + ] diff --git a/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py b/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py new file mode 100644 index 000000000..77867a8d2 --- /dev/null +++ b/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.1 on 2024-10-29 11:15 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("qfdmo", "0099_alter_action_couleur"), + ] + + operations = [ + migrations.RenameField( + model_name="action", + old_name="couleur", + new_name="couleur_foncee", + ), + ] diff --git a/qfdmo/migrations/0101_action_couleur_claire.py b/qfdmo/migrations/0101_action_couleur_claire.py new file mode 100644 index 000000000..7ec2dfaee --- /dev/null +++ b/qfdmo/migrations/0101_action_couleur_claire.py @@ -0,0 +1,58 @@ +# Generated by Django 5.1.1 on 2024-10-29 11:15 + +import colorfield.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("qfdmo", "0100_rename_couleur_action_couleur_foncee"), + ] + + operations = [ + migrations.AddField( + model_name="action", + name="couleur_claire", + field=colorfield.fields.ColorField( + blank=True, + choices=[ + ("#AEA397", "beige-gris-galet"), + ("#3558A2", "blue-cumulus-sun-368"), + ("#417DC4", "blue-cumulus"), + ("#bfccfb", "blue-ecume-850"), + ("#465F9D", "blue-ecume"), + ("#0055FF", "blue-france"), + ("#D1B781", "brown-cafe-creme-main-782"), + ("#D1B781", "brown-cafe-creme"), + ("#C08C65", "brown-caramel"), + ("#BD987A", "brown-opera"), + ("#009099", "green-archipel"), + ("#95e257", "green-bourgeon-850"), + ("#68A532", "green-bourgeon"), + ("#00A95F", "green-emeraude"), + ("#73e0cf", "green-menthe-850"), + ("#009081", "green-menthe-main-548"), + ("#37635f", "green-menthe-sun-373"), + ("#009081", "green-menthe"), + ("#B7A73F", "green-tilleul-verveine"), + ("#E4794A", "orange-terre-battue-main-645"), + ("#E4794A", "orange-terre-battue"), + ("#E18B76", "pink-macaron"), + ("#fcbfb7", "pink-tuile-850"), + ("#CE614A", "pink-tuile"), + ("#A558A0", "purple-glycine-main-494"), + ("#A558A0", "purple-glycine"), + ("#fcc63a", "yellow-moutarde-850"), + ("#C3992A", "yellow-moutarde"), + ("#e9c53b", "yellow-tournesol"), + ("#bb8568", "brown-caramel-sun-425-hover"), + ], + default="#C3992A", + image_field=None, + max_length=255, + null=True, + samples=None, + ), + ), + ] diff --git a/qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py b/qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py new file mode 100644 index 000000000..d74762f36 --- /dev/null +++ b/qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py @@ -0,0 +1,122 @@ +# Generated by Django 5.1.1 on 2024-10-29 11:18 + +import colorfield.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("qfdmo", "0101_action_couleur_claire"), + ] + + operations = [ + migrations.AlterField( + model_name="action", + name="couleur_claire", + field=colorfield.fields.ColorField( + blank=True, + choices=[ + ("#AEA397", "beige-gris-galet"), + ("#3558A2", "blue-cumulus-sun-368"), + ("#417DC4", "blue-cumulus"), + ("#bfccfb", "blue-ecume-850"), + ("#465F9D", "blue-ecume"), + ("#0055FF", "blue-france"), + ("#D1B781", "brown-cafe-creme-main-782"), + ("#D1B781", "brown-cafe-creme"), + ("#C08C65", "brown-caramel"), + ("#BD987A", "brown-opera"), + ("#009099", "green-archipel"), + ("#95e257", "green-bourgeon-850"), + ("#68A532", "green-bourgeon"), + ("#00A95F", "green-emeraude"), + ("#73e0cf", "green-menthe-850"), + ("#009081", "green-menthe-main-548"), + ("#37635f", "green-menthe-sun-373"), + ("#009081", "green-menthe"), + ("#B7A73F", "green-tilleul-verveine"), + ("#E4794A", "orange-terre-battue-main-645"), + ("#E4794A", "orange-terre-battue"), + ("#E18B76", "pink-macaron"), + ("#fcbfb7", "pink-tuile-850"), + ("#CE614A", "pink-tuile"), + ("#A558A0", "purple-glycine-main-494"), + ("#A558A0", "purple-glycine"), + ("#fcc63a", "yellow-moutarde-850"), + ("#C3992A", "yellow-moutarde"), + ("#e9c53b", "yellow-tournesol"), + ("#bb8568", "brown-caramel-sun-425-hover"), + ("#FEF3FD", "purple-glycine-975"), + ("#A558A0", "purple-glycine-main-494"), + ("#F3F6FE", "blue-cumulus-975"), + ("#417DC4", "blue-cumulus-main-526"), + ("#D1B781", "brown-cafe-creme-main-78"), + ("#F7ECDB", "brown-cafe-creme-950"), + ("#009081", "green-menthe-main-548"), + ("#DFFDF7", "green-menthe-975"), + ("#CE614A", "pink-tuile-main-556"), + ("#FEF4F3", "pink-tuile-975"), + ], + default="#C3992A", + image_field=None, + max_length=255, + null=True, + samples=None, + ), + ), + migrations.AlterField( + model_name="action", + name="couleur_foncee", + field=colorfield.fields.ColorField( + blank=True, + choices=[ + ("#AEA397", "beige-gris-galet"), + ("#3558A2", "blue-cumulus-sun-368"), + ("#417DC4", "blue-cumulus"), + ("#bfccfb", "blue-ecume-850"), + ("#465F9D", "blue-ecume"), + ("#0055FF", "blue-france"), + ("#D1B781", "brown-cafe-creme-main-782"), + ("#D1B781", "brown-cafe-creme"), + ("#C08C65", "brown-caramel"), + ("#BD987A", "brown-opera"), + ("#009099", "green-archipel"), + ("#95e257", "green-bourgeon-850"), + ("#68A532", "green-bourgeon"), + ("#00A95F", "green-emeraude"), + ("#73e0cf", "green-menthe-850"), + ("#009081", "green-menthe-main-548"), + ("#37635f", "green-menthe-sun-373"), + ("#009081", "green-menthe"), + ("#B7A73F", "green-tilleul-verveine"), + ("#E4794A", "orange-terre-battue-main-645"), + ("#E4794A", "orange-terre-battue"), + ("#E18B76", "pink-macaron"), + ("#fcbfb7", "pink-tuile-850"), + ("#CE614A", "pink-tuile"), + ("#A558A0", "purple-glycine-main-494"), + ("#A558A0", "purple-glycine"), + ("#fcc63a", "yellow-moutarde-850"), + ("#C3992A", "yellow-moutarde"), + ("#e9c53b", "yellow-tournesol"), + ("#bb8568", "brown-caramel-sun-425-hover"), + ("#FEF3FD", "purple-glycine-975"), + ("#A558A0", "purple-glycine-main-494"), + ("#F3F6FE", "blue-cumulus-975"), + ("#417DC4", "blue-cumulus-main-526"), + ("#D1B781", "brown-cafe-creme-main-78"), + ("#F7ECDB", "brown-cafe-creme-950"), + ("#009081", "green-menthe-main-548"), + ("#DFFDF7", "green-menthe-975"), + ("#CE614A", "pink-tuile-main-556"), + ("#FEF4F3", "pink-tuile-975"), + ], + default="#C3992A", + image_field=None, + max_length=255, + null=True, + samples=None, + ), + ), + ] diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index 735fe8041..9042ba0b1 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -381,12 +381,11 @@ def acteur_services_display(self): @cached_property def labels_display(self): - labels = list(self.labels.filter(afficher=True, bonus=False)) + return self.labels.filter(afficher=True).order_by("-bonus") - if label_bonus := self.labels.filter(afficher=True, bonus=True).first(): - labels.append(label_bonus) - - return labels + @cached_property + def is_bonus_reparation(self): + return self.labels.filter(afficher=True, bonus=True).exists() def proposition_services_by_direction(self, direction: str | None = None): if direction: diff --git a/qfdmo/models/action.py b/qfdmo/models/action.py index bc6d694b3..938ffd3ea 100644 --- a/qfdmo/models/action.py +++ b/qfdmo/models/action.py @@ -1,5 +1,6 @@ from typing import List, cast +from colorfield.fields import ColorField from django.contrib.gis.db import models from django.core.cache import cache from django.db.models.query import QuerySet @@ -51,6 +52,50 @@ def get_queryset(self): return GroupeActionQueryset(self.model, using=self._db) +COLOR_PALETTE = [ + ("#AEA397", "beige-gris-galet"), + ("#3558A2", "blue-cumulus-sun-368"), + ("#417DC4", "blue-cumulus"), + ("#bfccfb", "blue-ecume-850"), + ("#465F9D", "blue-ecume"), + ("#0055FF", "blue-france"), + ("#D1B781", "brown-cafe-creme-main-782"), + ("#D1B781", "brown-cafe-creme"), + ("#C08C65", "brown-caramel"), + ("#BD987A", "brown-opera"), + ("#009099", "green-archipel"), + ("#95e257", "green-bourgeon-850"), + ("#68A532", "green-bourgeon"), + ("#00A95F", "green-emeraude"), + ("#73e0cf", "green-menthe-850"), + ("#009081", "green-menthe-main-548"), + ("#37635f", "green-menthe-sun-373"), + ("#009081", "green-menthe"), + ("#B7A73F", "green-tilleul-verveine"), + ("#E4794A", "orange-terre-battue-main-645"), + ("#E4794A", "orange-terre-battue"), + ("#E18B76", "pink-macaron"), + ("#fcbfb7", "pink-tuile-850"), + ("#CE614A", "pink-tuile"), + ("#A558A0", "purple-glycine-main-494"), + ("#A558A0", "purple-glycine"), + ("#fcc63a", "yellow-moutarde-850"), + ("#C3992A", "yellow-moutarde"), + ("#e9c53b", "yellow-tournesol"), + ("#bb8568", "brown-caramel-sun-425-hover"), + ("#FEF3FD", "purple-glycine-975"), + ("#A558A0", "purple-glycine-main-494"), + ("#F3F6FE", "blue-cumulus-975"), + ("#417DC4", "blue-cumulus-main-526"), + ("#D1B781", "brown-cafe-creme-main-78"), + ("#F7ECDB", "brown-cafe-creme-950"), + ("#009081", "green-menthe-main-548"), + ("#DFFDF7", "green-menthe-975"), + ("#CE614A", "pink-tuile-main-556"), + ("#FEF4F3", "pink-tuile-975"), +] + + class GroupeAction(CodeAsNaturalKeyModel): objects = GroupeActionManager() @@ -100,13 +145,13 @@ class Meta: description = models.CharField(max_length=255, null=True, blank=True) order = models.IntegerField(blank=False, null=False, default=0) directions = models.ManyToManyField(ActionDirection, related_name="actions") - couleur = models.CharField( - max_length=255, - null=True, - blank=True, - default="yellow-tournesol", - help_text=COULEUR_FIELD_HELP_TEXT, + couleur_foncee = ColorField( + null=True, blank=True, default="#C3992A", max_length=255, choices=COLOR_PALETTE ) + couleur_claire = ColorField( + null=True, blank=True, default="#C3992A", max_length=255, choices=COLOR_PALETTE + ) + icon = models.CharField( max_length=255, null=True, diff --git a/requirements.in b/requirements.in index 84eac3c4c..2b547863d 100644 --- a/requirements.in +++ b/requirements.in @@ -25,3 +25,4 @@ whitenoise django-widget-tweaks django-cors-headers django-dsfr +django-colorfield diff --git a/requirements.txt b/requirements.txt index aeab5e115..ab1f95848 100644 --- a/requirements.txt +++ b/requirements.txt @@ -153,6 +153,10 @@ django==5.1.1 \ # django-ninja # django-sql-explorer # django-storages +django-colorfield==0.11.0 \ + --hash=sha256:05c38c8eb2a94938b810a19b2011846391a4ce71d1c92e88a35974fbcc8fc62e \ + --hash=sha256:460f40e6123b6ae0fb51a4eb86fc258fcdc0ea28f75102b685e8209b1eae9ec3 + # via -r requirements.in django-cors-headers==4.4.0 \ --hash=sha256:5c6e3b7fe870876a1efdfeb4f433782c3524078fa0dc9e0195f6706ce7a242f6 \ --hash=sha256:92cf4633e22af67a230a1456cb1b7a02bb213d6536d2dcb2a4a24092ea9cebc2 @@ -556,7 +560,9 @@ pillow==10.2.0 \ --hash=sha256:edca80cbfb2b68d7b56930b84a0e45ae1694aeba0541f798e908a49d66b837f1 \ --hash=sha256:f379abd2f1e3dddb2b61bc67977a6b5a0a3f7485538bcc6f39ec76163891ee48 \ --hash=sha256:fe4c15f6c9285dc54ce6553a3ce908ed37c8f3825b5a51a15c91442bb955b868 - # via -r requirements.in + # via + # -r requirements.in + # django-colorfield psycopg2==2.9.9 \ --hash=sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981 \ --hash=sha256:38a8dcc6856f569068b47de286b472b7c473ac7977243593a288ebce0dc89516 \ diff --git a/tailwind.config.js b/tailwind.config.js index cee300e50..c4ffea031 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -15,6 +15,8 @@ module.exports = { preflight: false, }, safelist: [ + "qfdmo-bg-[#DFFDF7]", // icone réparer + "qfdmo-border-[#009081]", // icone réparer "fr-icon-recycle-line", "fr-icon-arrow-go-back-line", "sm:qfdmo-max-w-[596px]", From de9fca15b7a753683a72298770d4da2fd5b55fc1 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 29 Oct 2024 13:12:00 +0100 Subject: [PATCH 025/109] remove comments --- .../src/search_solution_form_controller.ts | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index 601dd628a..fe060f54b 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -185,22 +185,6 @@ export default class extends Controller { showActeurDetailsPanel() { this.acteurDetailsPanelTarget.dataset.visible = "true" - - // mobile - // this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-0", "qfdmo-invisible") - // this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-full") - // this.acteurDetailsPanelTarget.classList.add("qfdmo-h-1/2") - // if (this.hasProposeAddressPanelTarget) { - // this.proposeAddressPanelTarget.classList.add("qfdmo-h-0", "qfdmo-invisible") - // } - // if (this.hasHeaderAddressPanelTarget) - // this.headerAddressPanelTarget.classList.remove("qfdmo-h-0", "qfdmo-invisible") - // this.collapseDetailsButtonTarget.classList.add("qfdmo-hidden") - // this.expandDetailsButtonTarget.classList.remove("qfdmo-hidden") - // desktop - // this.acteurDetailsPanelTarget.classList.add("sm:qfdmo-w-[480]") - // this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-full") - // this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-0") this.acteurDetailsPanelTarget.addEventListener( "animationend", () => { @@ -227,23 +211,6 @@ export default class extends Controller { { once: true }, ) clearActivePinpoints() - - // mobile - // this.acteurDetailsPanelTarget.classList.add("qfdmo-h-0", "qfdmo-invisible") - // this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-full") - // this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-1/2") - // if (this.hasProposeAddressPanelTarget) { - // // ???????????? - // this.proposeAddressPanelTarget.classList.remove("qfdmo-h-0", "qfdmo-invisible") - // } - // if (this.hasHeaderAddressPanelTarget) - // // ???????????? - // this.headerAddressPanelTarget.classList.remove("qfdmo-h-0", "qfdmo-invisible") - - // // desktop - // this.acteurDetailsPanelTarget.classList.add("sm:qfdmo-w-0") - // this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-full") - // this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-[480]") } displayFullDetails() { From 23603d67572f80078ddf8663a5de118f151b2748 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 29 Oct 2024 13:13:49 +0100 Subject: [PATCH 026/109] cleanup --- core/jinja2_handler.py | 4 +- jinja2/qfdmo/acteur/_detail.coucou | 394 ----------------------------- 2 files changed, 1 insertion(+), 397 deletions(-) delete mode 100644 jinja2/qfdmo/acteur/_detail.coucou diff --git a/core/jinja2_handler.py b/core/jinja2_handler.py index 5c17c9011..894b8cfcd 100644 --- a/core/jinja2_handler.py +++ b/core/jinja2_handler.py @@ -77,9 +77,7 @@ def distance_to_acteur(request, acteur): if distance_meters >= 1000: return f"({round(distance_meters / 1000, 1)} km)".replace(".", ",") else: - return ( - f"({round(distance_meters/10) * 10 } m)" # TODO : check nothing broke here - ) + return f"({round(distance_meters/10) * 10 } m)" def environment(**options): diff --git a/jinja2/qfdmo/acteur/_detail.coucou b/jinja2/qfdmo/acteur/_detail.coucou deleted file mode 100644 index 6095fba7c..000000000 --- a/jinja2/qfdmo/acteur/_detail.coucou +++ /dev/null @@ -1,394 +0,0 @@ -{# Acteur detail view content #} - -{% if adresse.labels.filter(afficher=True, bonus=True, type_enseigne=False) %} -

- Éligible au bonus réparation -

-{% elif adresse.labels.filter(afficher=True, type_enseigne=False).count() == 1 %} - {% with source_or_label=adresse.labels.filter(afficher=True, type_enseigne=False).first() %} - {% if source_or_label.logo_file %} - Ademe - Agence de la transition écologique - {% endif %} - {{ source_or_label.libelle }} - {% endwith %} -{% elif adresse.labels.filter(afficher=True, type_enseigne=False).count() >= 1 %} -

Cet établissement dispose de plusieurs labels

-{% elif adresse.labels.filter(afficher=True, type_enseigne=True).count() >= 1 %} - {% with source_or_label=adresse.labels.filter(afficher=True, type_enseigne=True).first() %} -

- {% if source_or_label.logo_file %} - Ademe - Agence de la transition écologique - {% endif %} - {{ source_or_label.libelle }} -

- {% endwith %} -{% endif %} - -

- {{ adresse.libelle }} -

- -

- {% for acteur_service in adresse.acteur_services_libelles_alpha_sorted %} - {{ acteur_service }}{% if not loop.last %}, {% endif %} - {% endfor %} - {{ distance_to_acteur(request, adresse) }} -

- -
-
- {% if latitude and longitude and not adresse.is_digital %} - - - Itinéraire - - {% endif %} - {% if adresse.url %} - - - - Site web - - {% endif %} - {% if adresse.email and False %} - - - E-mail - - {% endif %} - {% if adresse.telephone %} - - - Téléphone - - {% endif %} - -
- - - - Partager -
-
- - -
-
    -
  • - -
  • - {% if display_infos_panel(adresse) %} -
  • - -
  • - {% endif %} - {% if display_labels_panel %} -
  • - -
  • - {% endif %} - {% if display_sources_panel %} -
  • - -
  • - {% endif %} -
-
- - {% if adresse.description %} -

Description

-

{{ adresse.description }}

- {% endif %} - - {% if adresse.uniquement_sur_rdv %} -
-
-
- - Les services sont disponibles uniquement sur rendez-vous - -
-
-
- {% endif %} - - {% if display_exclusivite_reparation(adresse) %} -
-
-
- Répare uniquement les produits de ses marques -
-
-
- {% endif %} - -

Services disponibles

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

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

-

- {% for sous_categorie in service_proposition.sous_categories.all() %} - {{ sous_categorie }}{% if not loop.last %}, {% endif %} - {% endfor %} -

-
- {% endfor %} - - {% if adresse.labels.filter(afficher=True, bonus=True, type_enseigne=False) %} - - {% endif %} - -
- - {% if display_infos_panel(adresse) %} -
- {% if adresse.horaires_description %} -

Horaires d'ouverture

-
- {{ adresse.horaires_description.replace }} -
- {% endif %} - - {% if adresse.display_postal_address() %} -

Adresse

-
- {% if adresse.adresse %} - {{ adresse.adresse|title }}
- {% endif %} - {% if adresse.adresse_complement %} - {{ adresse.adresse_complement }}
- {% endif %} - {% if adresse.code_postal %} - {{ adresse.code_postal }} - {% endif %} - {% if adresse.ville %} - {{ adresse.ville|title }} - {% endif %} -
- {% endif %} - - {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=True) %} - {% if source_or_label_list %} -

Type d'enseigne

- {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=True) %} - {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} - {% endwith %} - {% endif %} - {% endwith %} - -
- {% endif %} - - {% if display_labels_panel %} -
- - {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=False) %} - {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} - {% endwith %} - -
- {% endif %} - - {% if display_sources_panel %} -
- {% with source_or_label_list=adresse.sources.all() %} - {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} - {% endwith %} -
- {% endif %} -
-
-
- Mis à jour le {{ adresse.modifie_le.strftime('%d/%m/%Y') }} -
-
- - - -{% if request.user.is_staff %} -
- Pour le staff : Lien vers l'admin -
-{% endif %} From 3f4416d7be76066326dcb38b26f12e395d46b778 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Tue, 29 Oct 2024 13:14:33 +0100 Subject: [PATCH 027/109] cleanup --- jinja2/qfdmo/acteur/_detail.html | 1 - 1 file changed, 1 deletion(-) delete mode 100644 jinja2/qfdmo/acteur/_detail.html diff --git a/jinja2/qfdmo/acteur/_detail.html b/jinja2/qfdmo/acteur/_detail.html deleted file mode 100644 index 28d0af969..000000000 --- a/jinja2/qfdmo/acteur/_detail.html +++ /dev/null @@ -1 +0,0 @@ -coucou From e49a9114114865a1c04d84deb4a248beab60495a Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 30 Oct 2024 18:16:56 +0100 Subject: [PATCH 028/109] Improve - responsive --- Makefile | 4 + jinja2/qfdmo/acteur/_actions.html | 8 +- jinja2/qfdmo/acteur/_label.html | 14 +- jinja2/qfdmo/acteur/_labels.html | 8 +- jinja2/qfdmo/acteur/_labels/bonus.html | 2 +- .../qfdmo/acteur/_labels/multiple_labels.html | 3 + jinja2/qfdmo/acteur/_tabs.html | 8 +- jinja2/qfdmo/acteur/tabs/labels_panel.html | 2 + jinja2/qfdmo/acteur/tabs/sections/bonus.html | 17 ++- jinja2/qfdmo/acteur/tabs/sources_panel.html | 6 +- jinja2/qfdmo/carte.html | 4 +- jinja2/qfdmo/carte/_header.html | 7 +- jinja2/qfdmo/carte/panels/acteur_detail.html | 18 ++- jinja2/qfdmo/shared/_map_container.html | 124 +++++++++--------- jinja2/qfdmo/shared/_result.html | 15 ++- parcel-transformers/dsfr.ts | 10 +- qfdmo/models/acteur.py | 10 +- scripts/restore_prod_locally.sh | 7 + static/to_compile/entrypoints/qfdmo.css | 18 ++- static/to_compile/src/map_controller.ts | 1 + .../src/search_solution_form_controller.ts | 22 ---- 21 files changed, 168 insertions(+), 140 deletions(-) create mode 100644 jinja2/qfdmo/acteur/_labels/multiple_labels.html create mode 100755 scripts/restore_prod_locally.sh diff --git a/Makefile b/Makefile index bd52e7bdd..9f4739a58 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,10 @@ createsuperuser: seed-database: $(DJANGO_ADMIN) loaddata categories actions acteur_services acteur_types +.PHONY: restore-prod +restore-prod: + ./scripts/restore_prod_locally.sh + # Dependencies management .PHONY: pip-update pip-update: diff --git a/jinja2/qfdmo/acteur/_actions.html b/jinja2/qfdmo/acteur/_actions.html index 6988344c2..4733084c9 100644 --- a/jinja2/qfdmo/acteur/_actions.html +++ b/jinja2/qfdmo/acteur/_actions.html @@ -1,5 +1,5 @@
{% if itineraire_url %} {% with text="Itinéraire",url=itineraire_url,icon="fr-icon-send-plane-line" %} @@ -13,12 +13,6 @@ {% endwith %} {% endif %} - {% if object.email %} - {% with text="E-mail",mailto=object.email,icon="fr-icon-mail-line",extra_classes="fr-btn--secondary-light" %} - {% include "qfdmo/acteur/_action_mailto.html" %} - {% endwith %} - {% endif %} - {% if object.telephone %} {% with text="Téléphone",tel=object.telephone,icon="fr-icon-phone-line",extra_classes="fr-btn--secondary-light" %} {% include "qfdmo/acteur/_action_tel.html" %} diff --git a/jinja2/qfdmo/acteur/_label.html b/jinja2/qfdmo/acteur/_label.html index 294080b19..962a45288 100644 --- a/jinja2/qfdmo/acteur/_label.html +++ b/jinja2/qfdmo/acteur/_label.html @@ -1,5 +1,14 @@ -
- + diff --git a/jinja2/qfdmo/acteur/_labels.html b/jinja2/qfdmo/acteur/_labels.html index 32d38bcc1..63a90e526 100644 --- a/jinja2/qfdmo/acteur/_labels.html +++ b/jinja2/qfdmo/acteur/_labels.html @@ -1,13 +1,9 @@
- {% if object.labels_display|length > 1 %} - {% with content="Cet établissement dispose de plusieurs labels",icon="fr-icon-shield-check-line" %} - {% include "qfdmo/shared/tag.html" %} - {% endwith %} - {% endif %} - {% with label=object.labels_display.first() %} {% if label.bonus %} {% include "qfdmo/acteur/_labels/bonus.html" %} + {% elif object.labels_display.filter(type_enseigne=False).count() > 1 %} + {% include "qfdmo/acteur/_labels/multiple_labels.html" %} {% else %} {% include "qfdmo/acteur/_labels/generic.html" %} {% endif %} diff --git a/jinja2/qfdmo/acteur/_labels/bonus.html b/jinja2/qfdmo/acteur/_labels/bonus.html index c31b70369..ad1b04b49 100644 --- a/jinja2/qfdmo/acteur/_labels/bonus.html +++ b/jinja2/qfdmo/acteur/_labels/bonus.html @@ -1,3 +1,3 @@ -{% with content="Éligible au bonus réparation",icon="fr-icon-percent-line",href="#bonus" %} +{% with content="Éligible au bonus réparation",icon="fr-icon-percent-line" %} {% include "qfdmo/shared/tag.html" %} {% endwith %} diff --git a/jinja2/qfdmo/acteur/_labels/multiple_labels.html b/jinja2/qfdmo/acteur/_labels/multiple_labels.html new file mode 100644 index 000000000..6acccbfa2 --- /dev/null +++ b/jinja2/qfdmo/acteur/_labels/multiple_labels.html @@ -0,0 +1,3 @@ +{% with content="Cet établissement dispose de plusieurs labels",icon="fr-icon-shield-check-line" %} + {% include "qfdmo/shared/tag.html" %} +{% endwith %} diff --git a/jinja2/qfdmo/acteur/_tabs.html b/jinja2/qfdmo/acteur/_tabs.html index 846734128..ace285caa 100644 --- a/jinja2/qfdmo/acteur/_tabs.html +++ b/jinja2/qfdmo/acteur/_tabs.html @@ -7,9 +7,11 @@ {% with text="Présentation",target="aboutPanel" %} {% include "qfdmo/acteur/tabs/_tab.html" %} {% endwith %} - {% with text="Labels",target="labelsPanel" %} - {% include "qfdmo/acteur/tabs/_tab.html" %} - {% endwith %} + {% if object.labels_display %} + {% with text="Labels",target="labelsPanel" %} + {% include "qfdmo/acteur/tabs/_tab.html" %} + {% endwith %} + {% endif %} {% with text="Sources",target="sourcesPanel" %} {% include "qfdmo/acteur/tabs/_tab.html" %} {% endwith %} diff --git a/jinja2/qfdmo/acteur/tabs/labels_panel.html b/jinja2/qfdmo/acteur/tabs/labels_panel.html index 65f168987..9fe29367d 100644 --- a/jinja2/qfdmo/acteur/tabs/labels_panel.html +++ b/jinja2/qfdmo/acteur/tabs/labels_panel.html @@ -5,7 +5,9 @@ {% block aria_labelledby %}labelsPanel{% endblock aria_labelledby %} {% block content %} +
{% for source_or_label in object.labels_display %} {% include "qfdmo/acteur/_label.html" %} {% endfor %} +
{% endblock content %} diff --git a/jinja2/qfdmo/acteur/tabs/sections/bonus.html b/jinja2/qfdmo/acteur/tabs/sections/bonus.html index 135b147cd..b9840c71d 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/bonus.html +++ b/jinja2/qfdmo/acteur/tabs/sections/bonus.html @@ -4,9 +4,22 @@ {% block title %} {# TODO : icone #} -Éligible au bonus réparation +Éligible au bonus réparation {% endblock title %} {% block content %} -Découvrez les réparations pour lesquelles vous pouvez bénéficier d'une aide et faites des économies. +
+ Découvrez les réparations pour lesquelles vous pouvez bénéficier d'une aide et faites des économies. +
+ + +En savoir plus + + {% endblock content %} diff --git a/jinja2/qfdmo/acteur/tabs/sources_panel.html b/jinja2/qfdmo/acteur/tabs/sources_panel.html index b4d9a9a02..d1b2e10fc 100644 --- a/jinja2/qfdmo/acteur/tabs/sources_panel.html +++ b/jinja2/qfdmo/acteur/tabs/sources_panel.html @@ -5,7 +5,7 @@ {% block aria_labelledby %}sourcesPanel{% endblock aria_labelledby %} {% block content %} -{% for source_or_label in object.sources.all() %} - {% include "qfdmo/acteur/_label.html" %} -{% endfor %} + {% for source_or_label in object.sources.all() %} + {% include "qfdmo/acteur/_label.html" %} + {% endfor %} {% endblock content %} diff --git a/jinja2/qfdmo/carte.html b/jinja2/qfdmo/carte.html index 8b183fb0f..69de00366 100644 --- a/jinja2/qfdmo/carte.html +++ b/jinja2/qfdmo/carte.html @@ -7,9 +7,9 @@
{% include "qfdmo/partials/featureflip_inputs.html" %} diff --git a/jinja2/qfdmo/carte/_header.html b/jinja2/qfdmo/carte/_header.html index 5e316cfc0..9dfaddf40 100644 --- a/jinja2/qfdmo/carte/_header.html +++ b/jinja2/qfdmo/carte/_header.html @@ -1,4 +1,7 @@ -
+
@@ -35,4 +38,4 @@
-
+ diff --git a/jinja2/qfdmo/carte/panels/acteur_detail.html b/jinja2/qfdmo/carte/panels/acteur_detail.html index 9d601f844..a40887594 100644 --- a/jinja2/qfdmo/carte/panels/acteur_detail.html +++ b/jinja2/qfdmo/carte/panels/acteur_detail.html @@ -3,18 +3,22 @@ tabindex="0" id="acteurDetailsPanel" class=" - qfdmo-absolute qfdmo-right-0 qfdmo-top-0 qfdmo-bottom-0 qfdmo-z-[3000] qfdmo-left-auto + md:qfdmo-absolute + qfdmo-right-0 qfdmo-top-0 qfdmo-bottom-0 qfdmo-z-[3000] qfdmo-left-auto qfdmo-bg-white qfdmo-drop-shadow-xl qfdmo-rounded-tl-sm qfdmo-rounded-bl-sm qfdmo-px-2w - qfdmo-w-[360px] + max-md:qfdmo-h-screen + md:qfdmo-w-[400px] qfdmo-w-full qfdmo-flex qfdmo-flex-col - qfdmo-fill-mode-forwards + md:qfdmo-fill-mode-forwards data-[visible=false]:qfdmo-hidden - data-[visible=true]:qfdmo-animate-in data-[visible=true]:qfdmo-flex - data-[visible=true]:qfdmo-slide-in-from-right-[360px] - data-[visible=exit]:qfdmo-animate-out - data-[visible=exit]:qfdmo-slide-out-to-right-[360px] + md:data-[visible=true]:qfdmo-animate-in + md:data-[visible=true]:qfdmo-ease-in + md:data-[visible=true]:qfdmo-slide-in-from-right-[400px] + md:data-[visible=exit]:qfdmo-animate-out + md:data-[visible=exit]:qfdmo-ease-out + md:data-[visible=exit]:qfdmo-slide-out-to-right-[400px] " data-search-solution-form-target="acteurDetailsPanel" data-visible="false" diff --git a/jinja2/qfdmo/shared/_map_container.html b/jinja2/qfdmo/shared/_map_container.html index 37b20fae2..9dfd35c9e 100644 --- a/jinja2/qfdmo/shared/_map_container.html +++ b/jinja2/qfdmo/shared/_map_container.html @@ -1,68 +1,66 @@ -
-
- {% if request.GET["digital"] == "1" %} - {% include "qfdmo/carte/_digital_results" %} - {% else %} - {# Near by addresses#} -
- {{ form.bounding_box }} -
- {% if is_carte(request) %} - - Proposer une adresse - - {% endif %} -
- {% include "qfdmo/shared/_search_in_zone.html" %} +{% if request.GET["digital"] == "1" %} + {% include "qfdmo/carte/_digital_results" %} +{% else %} + {# Near by addresses#} +
+ {{ form.bounding_box }} +
+ {% if is_carte(request) %} + + Proposer une adresse + + {% endif %} +
+ {% include "qfdmo/shared/_search_in_zone.html" %} - {% if is_carte(request) %} - {% include "qfdmo/carte/panels/legend.html" %} - {% endif %} + {% if is_carte(request) %} + {% include "qfdmo/carte/panels/legend.html" %} + {% endif %} - {% with address_ok=(form.initial.adresse or form.initial.bounding_box or acteurs) %} - {% include "qfdmo/shared/disclaimers/adresse_missing.html" %} - {% include "qfdmo/shared/disclaimers/no_local_solution.html" %} + {% with address_ok=(form.initial.adresse or form.initial.bounding_box or acteurs) %} + {% include "qfdmo/shared/disclaimers/adresse_missing.html" %} + {% include "qfdmo/shared/disclaimers/no_local_solution.html" %} - {% endwith %} - {% for acteur in acteurs %} - - {% endfor %} -
- {% endif %} + {% endwith %} + {% for acteur in acteurs %} + + {% endfor %}
- {% include "qfdmo/shared/disclaimers/loading_solutions.html" %} - {% if not is_carte(request) %} - - {% endif %} +{% endif %} +{% include "qfdmo/shared/disclaimers/loading_solutions.html" %} +{% if not is_carte(request) %} + +{% endif %} - {% include "qfdmo/carte/panels/acteur_detail.html" %} -
+{% include "qfdmo/carte/panels/acteur_detail.html" %} diff --git a/jinja2/qfdmo/shared/_result.html b/jinja2/qfdmo/shared/_result.html index 8abfdc99a..20649f4dc 100644 --- a/jinja2/qfdmo/shared/_result.html +++ b/jinja2/qfdmo/shared/_result.html @@ -1,11 +1,12 @@ {% block panel_header %}
{ - return purged.css - }) - .join("\n") + // source = purgeCSSResults + // .map((purged) => { + // return purged.css + // }) + // .join("\n") } asset.setCode(source) diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index 9042ba0b1..ee067b938 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -381,7 +381,15 @@ def acteur_services_display(self): @cached_property def labels_display(self): - return self.labels.filter(afficher=True).order_by("-bonus") + """ + On retourne une liste de labels qualité. + Dans la plupart des cas on ne retournera qu'un label, une future évolution + va intégrer la gestion des labels multiples. + + La spec suivie est la suivante : + - Si l'acteur dispose du bonus réparation : on l'affiche + """ + return self.labels.filter(afficher=True).order_by("-bonus", "type_enseigne") @cached_property def is_bonus_reparation(self): diff --git a/scripts/restore_prod_locally.sh b/scripts/restore_prod_locally.sh new file mode 100755 index 000000000..1c9b36cc3 --- /dev/null +++ b/scripts/restore_prod_locally.sh @@ -0,0 +1,7 @@ +DUMP_FILE=backup.pgsql +DATABASE_URL=postgres://qfdmo:qfdmo@localhost:6543/qfdmo # pragma: allowlist secret + +for table in $(psql "${DATABASE_URL}" -t -c "SELECT \"tablename\" FROM pg_tables WHERE schemaname='public'"); do + psql "${DATABASE_URL}" -c "DROP TABLE IF EXISTS \"${table}\" CASCADE;" +done +pg_restore -d "${DATABASE_URL}" --clean --no-acl --no-owner --no-privileges "${DUMP_FILE}" diff --git a/static/to_compile/entrypoints/qfdmo.css b/static/to_compile/entrypoints/qfdmo.css index eec9c0876..b558e3d60 100644 --- a/static/to_compile/entrypoints/qfdmo.css +++ b/static/to_compile/entrypoints/qfdmo.css @@ -194,15 +194,15 @@ DSFR customization for tabs } .fr-tabs__panel { - @apply qfdmo-py-1w qfdmo-px-0; + @apply qfdmo-py-1w qfdmo-px-0; } .fr-tabs__list { - @apply qfdmo-space-x-1w qfdmo-min-h-min; + @apply qfdmo-space-x-1w qfdmo-min-h-min; } .fr-tabs__tab { - @apply qfdmo-m-0; + @apply qfdmo-m-0; } } @@ -230,6 +230,14 @@ DSFR customization for tabs padding: 4px !important; } +.qfdmo-no-external-link-icon { + &, + .fr-link& { + &:after { + content: none; + } + } +} .fr-link--no-underline { background-image: none !important; } @@ -244,10 +252,6 @@ DSFR customization for tabs background-color: #dcdcfc !important; } -.qfdmo-no-external-link-icon:after { - content: none; -} - /* OPTIMIZE : solution temporaire, pour coller aux contraintes d'accessibilité * de Havas, cf https://www.notion.so/accelerateur-transition-ecologique-ademe/ACCESSIBILIT-CARTE-FORMULAIRE-Contr-le-segment-actif-pas-assez-clair-48f99736d566414d8d7ba5c1a6e24361?pvs=4 * À remonter au DSFR et supprimer lorqsu'ils l'auront implémenté. diff --git a/static/to_compile/src/map_controller.ts b/static/to_compile/src/map_controller.ts index 467cdb164..daf4a3c28 100644 --- a/static/to_compile/src/map_controller.ts +++ b/static/to_compile/src/map_controller.ts @@ -55,6 +55,7 @@ export default class extends Controller { } actorsMap.initEventListener() + window.location.hash = null window.addEventListener("hashchange", this.setActiveActor.bind(this)) } diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index fe060f54b..c5e52fcdc 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -24,7 +24,6 @@ export default class extends Controller { "proposeAddressPanel", "headerAddressPanel", - "expandDetailsButton", "collapseDetailsButton", "sousCategoryObjetGroup", @@ -79,7 +78,6 @@ export default class extends Controller { declare readonly hasProposeAddressPanelTarget: boolean declare readonly hasHeaderAddressPanelTarget: boolean - declare readonly expandDetailsButtonTarget: HTMLElement declare readonly collapseDetailsButtonTarget: HTMLElement declare readonly sousCategoryObjetGroupTarget: HTMLElement @@ -213,24 +211,6 @@ export default class extends Controller { clearActivePinpoints() } - displayFullDetails() { - // mobile - this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-0", "qfdmo-invisible") - this.acteurDetailsPanelTarget.classList.remove("qfdmo-h-1/2") - this.acteurDetailsPanelTarget.classList.add("qfdmo-h-full") - if (this.hasProposeAddressPanelTarget) { - this.proposeAddressPanelTarget.classList.add("qfdmo-h-0", "qfdmo-invisible") - } - if (this.hasHeaderAddressPanelTarget) - this.headerAddressPanelTarget.classList.add("qfdmo-h-0", "qfdmo-invisible") - this.collapseDetailsButtonTarget.classList.remove("qfdmo-hidden") - this.expandDetailsButtonTarget.classList.add("qfdmo-hidden") - // desktop - this.acteurDetailsPanelTarget.classList.add("sm:qfdmo-w-full") - this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-0") - this.acteurDetailsPanelTarget.classList.remove("sm:qfdmo-w-[480]") - } - displayDigitalActeur(event) { // TODO: refactor const identifiantUnique = event.currentTarget.dataset.identifiantUnique @@ -242,8 +222,6 @@ export default class extends Controller { } displayActeur({ detail: { identifiantUnique } }) { - console.log({ identifiantUnique}) - const latitude = this.latitudeInputTarget.value const longitude = this.longitudeInputTarget.value From a4e38c111e514179e07eef30d129a79ae9bf0d6e Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 30 Oct 2024 18:27:47 +0100 Subject: [PATCH 029/109] WIP --- jinja2/qfdmo/carte/panels/acteur_detail.html | 32 ++++---------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/jinja2/qfdmo/carte/panels/acteur_detail.html b/jinja2/qfdmo/carte/panels/acteur_detail.html index a40887594..49aac389d 100644 --- a/jinja2/qfdmo/carte/panels/acteur_detail.html +++ b/jinja2/qfdmo/carte/panels/acteur_detail.html @@ -24,35 +24,15 @@ data-visible="false" > {# Action buttons : open, close, minimize #} -
- - - -
- + {# Content #}
+ +
From 048fd0bfd08037c862f23aae0436e3ba38d78510 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Thu, 31 Oct 2024 12:02:17 +0100 Subject: [PATCH 030/109] Better split structure between viewsa --- jinja2/qfdmo/acteur/_detail.coucou | 394 ++++++++++++++++++ jinja2/qfdmo/carte.html | 54 +-- jinja2/qfdmo/carte/_header.html | 41 -- jinja2/qfdmo/carte/header.html | 39 ++ .../qfdmo/carte/{_result.html => result.html} | 0 jinja2/qfdmo/formulaire.html | 45 +- .../{_filters.html => advanced_filters.html} | 0 jinja2/qfdmo/formulaire/header.html | 9 + .../{_iframe_form.html => search_form.html} | 0 ...{_back_to_form.html => update_search.html} | 12 +- jinja2/qfdmo/shared/_header.html | 8 + jinja2/qfdmo/shared/_layout.html | 47 +++ jinja2/qfdmo/shared/_map_container.html | 2 +- qfdmo/models/action.py | 5 + .../src/search_solution_form_controller.ts | 6 +- 15 files changed, 552 insertions(+), 110 deletions(-) create mode 100644 jinja2/qfdmo/acteur/_detail.coucou delete mode 100644 jinja2/qfdmo/carte/_header.html create mode 100644 jinja2/qfdmo/carte/header.html rename jinja2/qfdmo/carte/{_result.html => result.html} (100%) rename jinja2/qfdmo/formulaire/{_filters.html => advanced_filters.html} (100%) create mode 100644 jinja2/qfdmo/formulaire/header.html rename jinja2/qfdmo/formulaire/{_iframe_form.html => search_form.html} (100%) rename jinja2/qfdmo/formulaire/{_back_to_form.html => update_search.html} (80%) create mode 100644 jinja2/qfdmo/shared/_header.html create mode 100644 jinja2/qfdmo/shared/_layout.html diff --git a/jinja2/qfdmo/acteur/_detail.coucou b/jinja2/qfdmo/acteur/_detail.coucou new file mode 100644 index 000000000..6095fba7c --- /dev/null +++ b/jinja2/qfdmo/acteur/_detail.coucou @@ -0,0 +1,394 @@ +{# Acteur detail view content #} + +{% if adresse.labels.filter(afficher=True, bonus=True, type_enseigne=False) %} +

+ Éligible au bonus réparation +

+{% elif adresse.labels.filter(afficher=True, type_enseigne=False).count() == 1 %} + {% with source_or_label=adresse.labels.filter(afficher=True, type_enseigne=False).first() %} + {% if source_or_label.logo_file %} + Ademe - Agence de la transition écologique + {% endif %} + {{ source_or_label.libelle }} + {% endwith %} +{% elif adresse.labels.filter(afficher=True, type_enseigne=False).count() >= 1 %} +

Cet établissement dispose de plusieurs labels

+{% elif adresse.labels.filter(afficher=True, type_enseigne=True).count() >= 1 %} + {% with source_or_label=adresse.labels.filter(afficher=True, type_enseigne=True).first() %} +

+ {% if source_or_label.logo_file %} + Ademe - Agence de la transition écologique + {% endif %} + {{ source_or_label.libelle }} +

+ {% endwith %} +{% endif %} + +

+ {{ adresse.libelle }} +

+ +

+ {% for acteur_service in adresse.acteur_services_libelles_alpha_sorted %} + {{ acteur_service }}{% if not loop.last %}, {% endif %} + {% endfor %} + {{ distance_to_acteur(request, adresse) }} +

+ +
+
+ {% if latitude and longitude and not adresse.is_digital %} + + + Itinéraire + + {% endif %} + {% if adresse.url %} + + + + Site web + + {% endif %} + {% if adresse.email and False %} + + + E-mail + + {% endif %} + {% if adresse.telephone %} + + + Téléphone + + {% endif %} + +
+ + + + Partager +
+
+ + +
+
    +
  • + +
  • + {% if display_infos_panel(adresse) %} +
  • + +
  • + {% endif %} + {% if display_labels_panel %} +
  • + +
  • + {% endif %} + {% if display_sources_panel %} +
  • + +
  • + {% endif %} +
+
+ + {% if adresse.description %} +

Description

+

{{ adresse.description }}

+ {% endif %} + + {% if adresse.uniquement_sur_rdv %} +
+
+
+ + Les services sont disponibles uniquement sur rendez-vous + +
+
+
+ {% endif %} + + {% if display_exclusivite_reparation(adresse) %} +
+
+
+ Répare uniquement les produits de ses marques +
+
+
+ {% endif %} + +

Services disponibles

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

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

+

+ {% for sous_categorie in service_proposition.sous_categories.all() %} + {{ sous_categorie }}{% if not loop.last %}, {% endif %} + {% endfor %} +

+
+ {% endfor %} + + {% if adresse.labels.filter(afficher=True, bonus=True, type_enseigne=False) %} + + {% endif %} + +
+ + {% if display_infos_panel(adresse) %} +
+ {% if adresse.horaires_description %} +

Horaires d'ouverture

+
+ {{ adresse.horaires_description.replace }} +
+ {% endif %} + + {% if adresse.display_postal_address() %} +

Adresse

+
+ {% if adresse.adresse %} + {{ adresse.adresse|title }}
+ {% endif %} + {% if adresse.adresse_complement %} + {{ adresse.adresse_complement }}
+ {% endif %} + {% if adresse.code_postal %} + {{ adresse.code_postal }} + {% endif %} + {% if adresse.ville %} + {{ adresse.ville|title }} + {% endif %} +
+ {% endif %} + + {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=True) %} + {% if source_or_label_list %} +

Type d'enseigne

+ {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=True) %} + {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} + {% endwith %} + {% endif %} + {% endwith %} + +
+ {% endif %} + + {% if display_labels_panel %} +
+ + {% with source_or_label_list=adresse.labels.filter(afficher=True, type_enseigne=False) %} + {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} + {% endwith %} + +
+ {% endif %} + + {% if display_sources_panel %} +
+ {% with source_or_label_list=adresse.sources.all() %} + {% include "qfdmo/_address_card_partials/source_or_label_list.html" %} + {% endwith %} +
+ {% endif %} +
+
+
+ Mis à jour le {{ adresse.modifie_le.strftime('%d/%m/%Y') }} +
+
+ + + +{% if request.user.is_staff %} +
+ Pour le staff : Lien vers l'admin +
+{% endif %} diff --git a/jinja2/qfdmo/carte.html b/jinja2/qfdmo/carte.html index 69de00366..70c0946fa 100644 --- a/jinja2/qfdmo/carte.html +++ b/jinja2/qfdmo/carte.html @@ -1,40 +1,28 @@ -{% extends base_template %} +{% extends "qfdmo/shared/_layout.html" %} - {% block content %} - - {# Controleur général de gestion de la navigation et du formulaire #} +{% block content_header %} + {# Panel Header #} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/header.html' %} +{% endblock content_header %} - - {% include "qfdmo/partials/featureflip_inputs.html" %} +{% block result %} + {# Panel Result #} + {% include 'qfdmo/carte/result.html' %} +{% endblock result %} - {# Panel Header #} - {# TODO: refacto turbo, should be moved outside of form #} - {% include 'qfdmo/carte/_header.html' %} +{% block everything_else %} + {# Panel «Filtres» #} + {% include 'qfdmo/carte/modals/filters.html' %} - {# Panel Result #} - {% include 'qfdmo/carte/_result.html' %} + {# Panel «Legend» #} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/panels/legend_mobile.html' %} - {# Panel «Filtres» #} - {% include 'qfdmo/carte/modals/filters.html' %} + {# Panel À propos #} - {# Panel «Legend» #} - {# TODO: refacto turbo, should be moved outside of form #} - {% include 'qfdmo/carte/panels/legend_mobile.html' %} + {# TODO: refacto turbo, should be moved outside of form #} + {% include 'qfdmo/carte/modals/a_propos.html' %} - {# Panel À propos #} - - {# TODO: refacto turbo, should be moved outside of form #} - {% include 'qfdmo/carte/modals/a_propos.html' %} - - {{ form.epci_codes }} - - - - {% include 'qfdmo/reparacteur_modale.html' %} - {% endblock %} + {{ form.epci_codes }} +{% endblock everything_else %} diff --git a/jinja2/qfdmo/carte/_header.html b/jinja2/qfdmo/carte/_header.html deleted file mode 100644 index 9dfaddf40..000000000 --- a/jinja2/qfdmo/carte/_header.html +++ /dev/null @@ -1,41 +0,0 @@ -
- - - {# Recherche adresse #} -
- {% include 'qfdmo/_addresses_partials/adresse_input_form.html' %} - -
- -
- - -
-
-
-
diff --git a/jinja2/qfdmo/carte/header.html b/jinja2/qfdmo/carte/header.html new file mode 100644 index 000000000..e846a9153 --- /dev/null +++ b/jinja2/qfdmo/carte/header.html @@ -0,0 +1,39 @@ +{% extends "qfdmo/shared/_header.html" %} +{% block content %} + + +{# Recherche adresse #} +
+ {% include 'qfdmo/_addresses_partials/adresse_input_form.html' %} + +
+ +
+ + +
+
+
+{% endblock content %} diff --git a/jinja2/qfdmo/carte/_result.html b/jinja2/qfdmo/carte/result.html similarity index 100% rename from jinja2/qfdmo/carte/_result.html rename to jinja2/qfdmo/carte/result.html diff --git a/jinja2/qfdmo/formulaire.html b/jinja2/qfdmo/formulaire.html index fcb94d959..6ee9e9ea7 100644 --- a/jinja2/qfdmo/formulaire.html +++ b/jinja2/qfdmo/formulaire.html @@ -1,34 +1,21 @@ -{% extends 'layout/base.html' %} +{% extends "qfdmo/shared/_layout.html" %} - {% block content %} - - {# Controleur général de gestion de la navigation et du formulaire #} +{% include "qfdmo/partials/featureflip_inputs.html" %} -
- {% include "qfdmo/partials/featureflip_inputs.html" %} +{% block content_header %} +{# Panel Filtres avancés et modifier ma recherche #} +{% include 'qfdmo/formulaire/header.html' %} +{% endblock content_header %} - {# Panel «Filtres avancés» #} - {% include 'qfdmo/formulaire/_filters.html' %} - {# Panel «Modifier ma recherche» #} - {% include 'qfdmo/formulaire/_back_to_form.html' %} +{% block result %} +{# Panel «Résultats de la recherche» #} +{% include 'qfdmo/shared/_result.html' %} +{% endblock result %} - {# Panel «Formulaire de recherche» #} - {% include 'qfdmo/formulaire/_iframe_form.html' %} - - {# Panel «Résultats de la recherche» #} - {% include 'qfdmo/shared/_result.html' %} - - {# Liens de pieds de page pour iframe #} - {% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} -
-
- - {% include 'qfdmo/reparacteur_modale.html' %} - {% endblock %} +{% block everything_else %} +{# Panel «Formulaire de recherche» #} +{% include 'qfdmo/formulaire/search_form.html' %} +{# Liens de pieds de page pour iframe #} +{% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %} +{% endblock everything_else %} diff --git a/jinja2/qfdmo/formulaire/_filters.html b/jinja2/qfdmo/formulaire/advanced_filters.html similarity index 100% rename from jinja2/qfdmo/formulaire/_filters.html rename to jinja2/qfdmo/formulaire/advanced_filters.html diff --git a/jinja2/qfdmo/formulaire/header.html b/jinja2/qfdmo/formulaire/header.html new file mode 100644 index 000000000..ecddb2dc8 --- /dev/null +++ b/jinja2/qfdmo/formulaire/header.html @@ -0,0 +1,9 @@ +{% extends "qfdmo/shared/_header.html" %} + +{% block content %} +{# Panel «Filtres avancés» #} +{% include 'qfdmo/formulaire/advanced_filters.html' %} + +{# Panel «Modifier ma recherche» #} +{% include 'qfdmo/formulaire/update_search.html' %} +{% endblock content %} diff --git a/jinja2/qfdmo/formulaire/_iframe_form.html b/jinja2/qfdmo/formulaire/search_form.html similarity index 100% rename from jinja2/qfdmo/formulaire/_iframe_form.html rename to jinja2/qfdmo/formulaire/search_form.html diff --git a/jinja2/qfdmo/formulaire/_back_to_form.html b/jinja2/qfdmo/formulaire/update_search.html similarity index 80% rename from jinja2/qfdmo/formulaire/_back_to_form.html rename to jinja2/qfdmo/formulaire/update_search.html index 19d973481..451c6dfed 100644 --- a/jinja2/qfdmo/formulaire/_back_to_form.html +++ b/jinja2/qfdmo/formulaire/update_search.html @@ -1,7 +1,11 @@ -
-{% endblock content %} diff --git a/jinja2/qfdmo/shared/_header.html b/jinja2/qfdmo/shared/_header.html deleted file mode 100644 index eef395f76..000000000 --- a/jinja2/qfdmo/shared/_header.html +++ /dev/null @@ -1,8 +0,0 @@ -
- - {% block content %} - {% endblock content %} -
diff --git a/jinja2/qfdmo/shared/_layout.html b/jinja2/qfdmo/shared/_layout.html deleted file mode 100644 index 163cea911..000000000 --- a/jinja2/qfdmo/shared/_layout.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends base_template %} - - {% block content %} - - {# Controleur général de gestion de la navigation et du formulaire #} - -
-
-
- {% block content_header %} - {% endblock content_header %} -
- -
- {% block result %} - {% include 'qfdmo/shared/_result.html' %} - {% endblock result %} - - - {% block everything_else %} - {% endblock everything_else %} - - {% block form %} - {% include "qfdmo/partials/featureflip_inputs.html" %} - {{ form.bounding_box }} - {% endblock form %} -
- - -
- {% block content_footer %} - {% endblock content_footer %} -
- -
-
-
- - {% include 'qfdmo/reparacteur_modale.html' %} - {% endblock %} diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html new file mode 100644 index 000000000..06db702e0 --- /dev/null +++ b/jinja2/qfdmo/shared/_main.html @@ -0,0 +1,115 @@ +{% extends base_template %} + +{% block content %} + + {# Controleur général de gestion de la navigation et du formulaire #} +
+
+
+ {% block content_header %} + {% endblock content_header %} +
+ + {# + We need to set a size on the map to help Leaflet size its content. + We do not want the map to be bigger than the height of its container + + The values of 120px and 150px are determined empirically. + They need to match the css variables used for .grid-map selector in qfdmo.css + #} +
+ {% block result %} + + {% include 'qfdmo/shared/_map_container.html' %} + + {% endblock result %} + + {% block everything_else %} + {% endblock everything_else %} + + {% block form %} + {% include "qfdmo/partials/featureflip_inputs.html" %} + {{ form.bounding_box }} + {% endblock form %} +
+ + +
+ {% block content_footer %} + {% endblock content_footer %} +
+
+
+
+ +{% include 'qfdmo/reparacteur_modale.html' %} +{% endblock content %} diff --git a/jinja2/qfdmo/shared/_map_container.html b/jinja2/qfdmo/shared/_map_container.html index af4f8c06a..68c82163a 100644 --- a/jinja2/qfdmo/shared/_map_container.html +++ b/jinja2/qfdmo/shared/_map_container.html @@ -10,12 +10,6 @@ class=" qfdmo-relative qfdmo-flex-grow - {% if is_carte %} - qfdmo-h-[calc(100vh_-_120px)] - {% else %} - qfdmo-h-[calc(100vh_-_250px)] - {% endif %} - md:qfdmo-relative qfdmo-shadow " > diff --git a/jinja2/qfdmo/shared/_result.html b/jinja2/qfdmo/shared/_result.html deleted file mode 100644 index 6ce811421..000000000 --- a/jinja2/qfdmo/shared/_result.html +++ /dev/null @@ -1,12 +0,0 @@ - - {% include 'qfdmo/shared/_map_container.html' %} - diff --git a/jinja2/qfdmo/shared/_search_form_data-attributes.html b/jinja2/qfdmo/shared/_search_form_data-attributes.html deleted file mode 100644 index 559b76b0e..000000000 --- a/jinja2/qfdmo/shared/_search_form_data-attributes.html +++ /dev/null @@ -1,10 +0,0 @@ -data-controller="search-solution-form" id='search_form' -data-search-solution-form-target="searchForm" -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 -ss-cat-object-autocomplete:optionSelected->search-solution-form#checkSsCatObjetErrorForm -address-autocomplete:optionSelected->search-solution-form#advancedSubmit -address-autocomplete:formSubmit->search-solution-form#advancedSubmit -ss-cat-object-autocomplete:formSubmit->search-solution-form#advancedSubmit" diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index ee067b938..af8d25297 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -200,7 +200,7 @@ def with_bonus(self): def digital(self): return ( - self.filter(acteur_type_id=ActeurType.get_digital_acteur_type_id()) + self.filter(acteur_type__code="acteur_digital") .annotate(min_action_order=Min("proposition_services__action__order")) .order_by("min_action_order", "?") ) diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index ad033fcd1..b73cf44d5 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -247,7 +247,7 @@ def get_context_data(self, **kwargs): acteurs = self._acteurs_from_sous_categorie_objet_and_actions() if self.get_data_from_request_or_bounded_form("digital") == "1": - acteurs = acteurs.digital() + acteurs = acteurs.digital()[:100] else: bbox, acteurs = self._bbox_and_acteurs_from_location_or_epci(acteurs) # acteurs = acteurs.values() diff --git a/static/to_compile/entrypoints/qfdmo.css b/static/to_compile/entrypoints/qfdmo.css index 940912a4a..f2dca65ba 100644 --- a/static/to_compile/entrypoints/qfdmo.css +++ b/static/to_compile/entrypoints/qfdmo.css @@ -269,15 +269,12 @@ DSFR customization for tabs } .map-grid { ---footer-height: 0; ---header-height: 120px; -min-height: 100vh; - display: grid; - grid-auto-flow: row dense; - /* grid-template-columns: 1fr 400px; */ + --footer-height: 0; + --header-height: 120px; + @apply qfdmo-min-h-screen md:qfdmo-grid qfdmo-gap-0; + @apply qfdmo-grid-flow-row-dense; grid-template-columns: 1fr auto; grid-template-rows: var(--header-height) 1.5fr var(--footer-height); - gap: 0px 0px; grid-template-areas: "header header" "map detail" @@ -295,8 +292,7 @@ min-height: 100vh; grid-area: map; } .formulaire & { - --footer-height: 100px; - --header-height: 135px; - + --footer-height: 100px; + --header-height: 135px; } } diff --git a/static/to_compile/src/map_controller.ts b/static/to_compile/src/map_controller.ts index e7349e1fd..85ad6dfbc 100644 --- a/static/to_compile/src/map_controller.ts +++ b/static/to_compile/src/map_controller.ts @@ -63,7 +63,6 @@ export default class extends Controller { actorsMap.initEventListener() removeHash() - window.addEventListener("hashchange", this.setActiveActor.bind(this)) } initialize() { @@ -82,15 +81,4 @@ export default class extends Controller { hideSearchInZoneButton() { this.searchInZoneButtonTarget.classList.add("qfdmo-hidden") } - - setActiveActor(event?: HashChangeEvent) { - const identifiantUnique = event - ? new URL(event.newURL).hash.substring(1) - : window.location.hash.substring(1) - - console.log({ identifiantUnique }) - - this.dispatch("displayActeur", { detail: { identifiantUnique } }) - this.dispatch("captureInteraction") - } } diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index dd3c98e86..9053f6495 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -111,12 +111,21 @@ export default class extends Controller { connect() { this.displayActionList() + window.addEventListener("hashchange", this.#setActiveActor.bind(this)) if (!this.isIframeValue) { this.scrollToContent() } } + #setActiveActor(event?: HashChangeEvent) { + const identifiantUnique = event + ? new URL(event.newURL).hash.substring(1) + : window.location.hash.substring(1) + + this.displayActeur(identifiantUnique) + this.dispatch("captureInteraction") + } activeReparerFilters(activate: boolean = true) { // Carte mode this.activeReparerFiltersCarte() @@ -184,13 +193,7 @@ export default class extends Controller { showActeurDetailsPanel() { this.acteurDetailsPanelTarget.dataset.visible = "true" - this.acteurDetailsPanelTarget.addEventListener( - "animationend", - () => { - this.acteurDetailsPanelTarget.focus() - }, - { once: true }, - ) + this.acteurDetailsPanelTarget.scrollIntoView() } updateBboxInput(event) { @@ -201,7 +204,7 @@ export default class extends Controller { document .querySelector("[aria-controls=acteurDetailsPanel][aria-expanded=true]") ?.setAttribute("aria-expanded", "false") - this.acteurDetailsPanelTarget.dataset.visible = "false" + this.acteurDetailsPanelTarget.dataset.visible = "exit" this.acteurDetailsPanelTarget.addEventListener( "animationend", () => { @@ -213,8 +216,8 @@ export default class extends Controller { } displayDigitalActeur(event) { - // TODO: refactor const identifiantUnique = event.currentTarget.dataset.identifiantUnique + window.location.hash = identifiantUnique document .querySelector("[aria-controls='acteurDetailsPanel'][aria-expanded='true']") ?.setAttribute("aria-expanded", "false") @@ -222,7 +225,7 @@ export default class extends Controller { this.showActeurDetailsPanel() } - displayActeur({ detail: { identifiantUnique } }) { + displayActeur(identifiantUnique) { const latitude = this.latitudeInputTarget.value const longitude = this.longitudeInputTarget.value @@ -372,7 +375,7 @@ export default class extends Controller { this.advancedFiltersMainPanelTarget.addEventListener( "animationend", () => { - this.advancedFiltersMainPanelTarget.focus() + // this.advancedFiltersMainPanelTarget.focus() }, { once: true }, ) From ab547509948f81a4211775828a71a673fa450ca6 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Thu, 31 Oct 2024 18:04:39 +0100 Subject: [PATCH 034/109] WIP --- Procfile.dev | 2 +- jinja2/qfdmo/acteur/_action.html | 3 +++ jinja2/qfdmo/acteur/_actions.html | 2 +- jinja2/qfdmo/acteur/tabs/_section.html | 2 +- jinja2/qfdmo/acteur/tabs/about_panel.html | 4 ++++ jinja2/qfdmo/acteur/tabs/sections/telephone.html | 15 +++++++++++++++ .../src/search_solution_form_controller.ts | 2 ++ 7 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 jinja2/qfdmo/acteur/tabs/sections/telephone.html diff --git a/Procfile.dev b/Procfile.dev index efd581a94..61252cb24 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,3 @@ services: docker compose --profile lvao up -web: .venv/bin/python manage.py runserver +web: .venv/bin/python manage.py runserver 0.0.0.0:8000 npm: npm run watch diff --git a/jinja2/qfdmo/acteur/_action.html b/jinja2/qfdmo/acteur/_action.html index 5bb1a7af3..7b49fc4f0 100644 --- a/jinja2/qfdmo/acteur/_action.html +++ b/jinja2/qfdmo/acteur/_action.html @@ -3,6 +3,9 @@ qfdmo-flex qfdmo-flex-col qfdmo-items-center qfdmo-bg-none qfdmo-no-external-link-icon qfdmo-space-y-1v + {% if mobile_only %} + md:qfdmo-hidden + {% endif %} " href="{% block href %}{{ url }}{% endblock href %}" title="{{ title }}" diff --git a/jinja2/qfdmo/acteur/_actions.html b/jinja2/qfdmo/acteur/_actions.html index 4733084c9..5ceef8d94 100644 --- a/jinja2/qfdmo/acteur/_actions.html +++ b/jinja2/qfdmo/acteur/_actions.html @@ -14,7 +14,7 @@ {% endif %} {% if object.telephone %} - {% with text="Téléphone",tel=object.telephone,icon="fr-icon-phone-line",extra_classes="fr-btn--secondary-light" %} + {% with text="Téléphone",tel=object.telephone,icon="fr-icon-phone-line",extra_classes="fr-btn--secondary-light md:qfdmo-hidden",mobile_only=True %} {% include "qfdmo/acteur/_action_tel.html" %} {% endwith %} {% endif %} diff --git a/jinja2/qfdmo/acteur/tabs/_section.html b/jinja2/qfdmo/acteur/tabs/_section.html index 6a71a1fd2..5b82167b2 100644 --- a/jinja2/qfdmo/acteur/tabs/_section.html +++ b/jinja2/qfdmo/acteur/tabs/_section.html @@ -1,5 +1,5 @@
-

+

{% block title %} {% endblock title %}

diff --git a/jinja2/qfdmo/acteur/tabs/about_panel.html b/jinja2/qfdmo/acteur/tabs/about_panel.html index 6aa58881a..d5d857e28 100644 --- a/jinja2/qfdmo/acteur/tabs/about_panel.html +++ b/jinja2/qfdmo/acteur/tabs/about_panel.html @@ -12,6 +12,10 @@ {% include "qfdmo/acteur/tabs/sections/adresse.html" %} {% endif %} + {% if object.telephone %} + {% include "qfdmo/acteur/tabs/sections/telephone.html" %} + {% endif %} + {% if object.description %} {% include "qfdmo/acteur/tabs/sections/description.html" %} {% endif %} diff --git a/jinja2/qfdmo/acteur/tabs/sections/telephone.html b/jinja2/qfdmo/acteur/tabs/sections/telephone.html new file mode 100644 index 000000000..23f2561cc --- /dev/null +++ b/jinja2/qfdmo/acteur/tabs/sections/telephone.html @@ -0,0 +1,15 @@ +{% extends "qfdmo/acteur/tabs/_section.html" %} + +{% block title %}{% endblock title %} + +{% block wrapper_attrs %} +class="max-md:qfdmo-hidden" +{% endblock %} + +{% block content %} +

+ + + {{ object.telephone }} +

+{% endblock content %} diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index 9053f6495..73e0e2924 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -112,6 +112,8 @@ export default class extends Controller { connect() { this.displayActionList() window.addEventListener("hashchange", this.#setActiveActor.bind(this)) + // Prevents the leaflet map to move when the user moves panel + this.acteurDetailsPanelTarget.addEventListener("touchmove", event => event.stopPropagation()) if (!this.isIframeValue) { this.scrollToContent() From 23631ba408914ed933648be43199b8365a0e2a99 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Thu, 31 Oct 2024 18:21:26 +0100 Subject: [PATCH 035/109] WIP --- jinja2/qfdmo/shared/_main.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html index 06db702e0..975af6576 100644 --- a/jinja2/qfdmo/shared/_main.html +++ b/jinja2/qfdmo/shared/_main.html @@ -25,7 +25,7 @@
{% block content_header %} {% endblock content_header %} @@ -41,13 +41,15 @@
{% block result %} Date: Thu, 31 Oct 2024 21:01:58 +0100 Subject: [PATCH 036/109] WIP --- .secrets.baseline | 4 +- jinja2/layout/base.html | 43 +++++++------- jinja2/qfdmo/configurator/advanced.html | 3 + jinja2/qfdmo/configurator/base.html | 2 + jinja2/qfdmo/shared/_main.html | 2 +- qfdmo/migrations/0099_alter_action_couleur.py | 58 ------------------- ...2_alter_action_couleur_claire_and_more.py} | 18 +++++- ...00_rename_couleur_action_couleur_foncee.py | 18 ------ .../migrations/0101_action_couleur_claire.py | 58 ------------------- ...03_rename_couleur_foncee_action_couleur.py | 21 +++++++ qfdmo/models/acteur.py | 1 + qfdmo/models/action.py | 7 ++- unit_tests/core/test_jinja2_handler.py | 22 ------- unit_tests/qfdmo/test_acteur.py | 8 ++- unit_tests/qfdmo/test_addresses_view.py | 45 +++++++++++++- 15 files changed, 119 insertions(+), 191 deletions(-) delete mode 100644 qfdmo/migrations/0099_alter_action_couleur.py rename qfdmo/migrations/{0102_alter_action_couleur_claire_and_more.py => 0099_alter_action_couleur_squashed_0102_alter_action_couleur_claire_and_more.py} (91%) delete mode 100644 qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py delete mode 100644 qfdmo/migrations/0101_action_couleur_claire.py create mode 100644 qfdmo/migrations/0103_rename_couleur_foncee_action_couleur.py diff --git a/.secrets.baseline b/.secrets.baseline index 096f9727e..ffb55928b 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -178,7 +178,7 @@ "filename": "jinja2/layout/base.html", "hashed_secret": "057dece35d736a3ae1e710a9cba3f080bd101cde", "is_verified": false, - "line_number": 75 + "line_number": 73 } ], "static/to_compile/src/analytics.ts": [ @@ -207,5 +207,5 @@ } ] }, - "generated_at": "2024-10-31T14:52:03Z" + "generated_at": "2024-10-31T20:01:37Z" } diff --git a/jinja2/layout/base.html b/jinja2/layout/base.html index d1802b50a..3528de7d1 100644 --- a/jinja2/layout/base.html +++ b/jinja2/layout/base.html @@ -67,32 +67,31 @@

Une mise à jour de votre navigateur est nécessaire {% endif %} {% block js %} - {% endblock js %} + {% if is_embedded %} + + {% endif %} - {% if is_embedded %} - - {% endif %} + {% if request.user.is_authenticated %} + + {% endif %} - {% if request.user.is_authenticated %} - - {% endif %} - - + {% endblock js %} diff --git a/jinja2/qfdmo/configurator/advanced.html b/jinja2/qfdmo/configurator/advanced.html index 11a5fd3be..4b8778a50 100644 --- a/jinja2/qfdmo/configurator/advanced.html +++ b/jinja2/qfdmo/configurator/advanced.html @@ -112,3 +112,6 @@

Configurateur d'Iframe

{% include "qfdmo/configurator/_iframe.html"%}
{% endblock content %} + + +{% block js %}{% endblock js %} diff --git a/jinja2/qfdmo/configurator/base.html b/jinja2/qfdmo/configurator/base.html index 099cad15d..284f4ba67 100644 --- a/jinja2/qfdmo/configurator/base.html +++ b/jinja2/qfdmo/configurator/base.html @@ -71,3 +71,5 @@

Prévisualisation

{% endif %}
{% endblock content %} + +{% block js %}{% endblock js %} diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html index 975af6576..f58b5e5f5 100644 --- a/jinja2/qfdmo/shared/_main.html +++ b/jinja2/qfdmo/shared/_main.html @@ -78,7 +78,7 @@ qfdmo-relative qfdmo-z-50 qfdmo-flex qfdmo-flex-col - qfdmo-h-screen + qfdmo-min-h-screen {% if is_carte %} md:qfdmo-h-[calc(100vh_-_120px)] {% else %} diff --git a/qfdmo/migrations/0099_alter_action_couleur.py b/qfdmo/migrations/0099_alter_action_couleur.py deleted file mode 100644 index 9538a1af1..000000000 --- a/qfdmo/migrations/0099_alter_action_couleur.py +++ /dev/null @@ -1,58 +0,0 @@ -# Generated by Django 5.1.1 on 2024-10-29 11:15 - -import colorfield.fields -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("qfdmo", "0098_alter_action_couleur_alter_groupeaction_couleur"), - ] - - operations = [ - migrations.AlterField( - model_name="action", - name="couleur", - field=colorfield.fields.ColorField( - blank=True, - choices=[ - ("#AEA397", "beige-gris-galet"), - ("#3558A2", "blue-cumulus-sun-368"), - ("#417DC4", "blue-cumulus"), - ("#bfccfb", "blue-ecume-850"), - ("#465F9D", "blue-ecume"), - ("#0055FF", "blue-france"), - ("#D1B781", "brown-cafe-creme-main-782"), - ("#D1B781", "brown-cafe-creme"), - ("#C08C65", "brown-caramel"), - ("#BD987A", "brown-opera"), - ("#009099", "green-archipel"), - ("#95e257", "green-bourgeon-850"), - ("#68A532", "green-bourgeon"), - ("#00A95F", "green-emeraude"), - ("#73e0cf", "green-menthe-850"), - ("#009081", "green-menthe-main-548"), - ("#37635f", "green-menthe-sun-373"), - ("#009081", "green-menthe"), - ("#B7A73F", "green-tilleul-verveine"), - ("#E4794A", "orange-terre-battue-main-645"), - ("#E4794A", "orange-terre-battue"), - ("#E18B76", "pink-macaron"), - ("#fcbfb7", "pink-tuile-850"), - ("#CE614A", "pink-tuile"), - ("#A558A0", "purple-glycine-main-494"), - ("#A558A0", "purple-glycine"), - ("#fcc63a", "yellow-moutarde-850"), - ("#C3992A", "yellow-moutarde"), - ("#e9c53b", "yellow-tournesol"), - ("#bb8568", "brown-caramel-sun-425-hover"), - ], - default="#C3992A", - image_field=None, - max_length=255, - null=True, - samples=None, - ), - ), - ] diff --git a/qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py b/qfdmo/migrations/0099_alter_action_couleur_squashed_0102_alter_action_couleur_claire_and_more.py similarity index 91% rename from qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py rename to qfdmo/migrations/0099_alter_action_couleur_squashed_0102_alter_action_couleur_claire_and_more.py index d74762f36..37f4d3380 100644 --- a/qfdmo/migrations/0102_alter_action_couleur_claire_and_more.py +++ b/qfdmo/migrations/0099_alter_action_couleur_squashed_0102_alter_action_couleur_claire_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-10-29 11:18 +# Generated by Django 5.1.1 on 2024-10-31 19:26 import colorfield.fields from django.db import migrations @@ -6,12 +6,24 @@ class Migration(migrations.Migration): - dependencies = [ + replaces = [ + ("qfdmo", "0099_alter_action_couleur"), + ("qfdmo", "0100_rename_couleur_action_couleur_foncee"), ("qfdmo", "0101_action_couleur_claire"), + ("qfdmo", "0102_alter_action_couleur_claire_and_more"), + ] + + dependencies = [ + ("qfdmo", "0098_alter_action_couleur_alter_groupeaction_couleur"), ] operations = [ - migrations.AlterField( + migrations.RenameField( + model_name="action", + old_name="couleur", + new_name="couleur_foncee", + ), + migrations.AddField( model_name="action", name="couleur_claire", field=colorfield.fields.ColorField( diff --git a/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py b/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py deleted file mode 100644 index 77867a8d2..000000000 --- a/qfdmo/migrations/0100_rename_couleur_action_couleur_foncee.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.1.1 on 2024-10-29 11:15 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("qfdmo", "0099_alter_action_couleur"), - ] - - operations = [ - migrations.RenameField( - model_name="action", - old_name="couleur", - new_name="couleur_foncee", - ), - ] diff --git a/qfdmo/migrations/0101_action_couleur_claire.py b/qfdmo/migrations/0101_action_couleur_claire.py deleted file mode 100644 index 7ec2dfaee..000000000 --- a/qfdmo/migrations/0101_action_couleur_claire.py +++ /dev/null @@ -1,58 +0,0 @@ -# Generated by Django 5.1.1 on 2024-10-29 11:15 - -import colorfield.fields -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("qfdmo", "0100_rename_couleur_action_couleur_foncee"), - ] - - operations = [ - migrations.AddField( - model_name="action", - name="couleur_claire", - field=colorfield.fields.ColorField( - blank=True, - choices=[ - ("#AEA397", "beige-gris-galet"), - ("#3558A2", "blue-cumulus-sun-368"), - ("#417DC4", "blue-cumulus"), - ("#bfccfb", "blue-ecume-850"), - ("#465F9D", "blue-ecume"), - ("#0055FF", "blue-france"), - ("#D1B781", "brown-cafe-creme-main-782"), - ("#D1B781", "brown-cafe-creme"), - ("#C08C65", "brown-caramel"), - ("#BD987A", "brown-opera"), - ("#009099", "green-archipel"), - ("#95e257", "green-bourgeon-850"), - ("#68A532", "green-bourgeon"), - ("#00A95F", "green-emeraude"), - ("#73e0cf", "green-menthe-850"), - ("#009081", "green-menthe-main-548"), - ("#37635f", "green-menthe-sun-373"), - ("#009081", "green-menthe"), - ("#B7A73F", "green-tilleul-verveine"), - ("#E4794A", "orange-terre-battue-main-645"), - ("#E4794A", "orange-terre-battue"), - ("#E18B76", "pink-macaron"), - ("#fcbfb7", "pink-tuile-850"), - ("#CE614A", "pink-tuile"), - ("#A558A0", "purple-glycine-main-494"), - ("#A558A0", "purple-glycine"), - ("#fcc63a", "yellow-moutarde-850"), - ("#C3992A", "yellow-moutarde"), - ("#e9c53b", "yellow-tournesol"), - ("#bb8568", "brown-caramel-sun-425-hover"), - ], - default="#C3992A", - image_field=None, - max_length=255, - null=True, - samples=None, - ), - ), - ] diff --git a/qfdmo/migrations/0103_rename_couleur_foncee_action_couleur.py b/qfdmo/migrations/0103_rename_couleur_foncee_action_couleur.py new file mode 100644 index 000000000..d989f0f8d --- /dev/null +++ b/qfdmo/migrations/0103_rename_couleur_foncee_action_couleur.py @@ -0,0 +1,21 @@ +# Generated by Django 5.1.1 on 2024-10-31 19:36 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "qfdmo", + "0099_alter_action_couleur_squashed_0102_alter_action_couleur_claire_and_more", + ), + ] + + operations = [ + migrations.RenameField( + model_name="action", + old_name="couleur_foncee", + new_name="couleur", + ), + ] diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index af8d25297..2e69ad615 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -368,6 +368,7 @@ def sorted_proposition_services(self): @cached_property def acteur_services_libelles_alpha_sorted(self) -> list[str]: + # TODO : rename this method...... return list( self.acteur_services.exclude(libelle=None) .order_by("libelle") diff --git a/qfdmo/models/action.py b/qfdmo/models/action.py index 7f25aff2c..617bb0446 100644 --- a/qfdmo/models/action.py +++ b/qfdmo/models/action.py @@ -115,6 +115,7 @@ class Meta: default="yellow-tournesol", help_text=COULEUR_FIELD_HELP_TEXT, ) + icon = models.CharField( max_length=255, null=True, @@ -145,13 +146,13 @@ class Meta: description = models.CharField(max_length=255, null=True, blank=True) order = models.IntegerField(blank=False, null=False, default=0) directions = models.ManyToManyField(ActionDirection, related_name="actions") - couleur_foncee = ColorField( + couleur = ColorField( null=True, blank=True, default="#C3992A", max_length=255, choices=COLOR_PALETTE ) @property - def couleur(self): - return self.couleur_foncee + def couleur_foncee(self): + return self.couleur couleur_claire = ColorField( null=True, blank=True, default="#C3992A", max_length=255, choices=COLOR_PALETTE diff --git a/unit_tests/core/test_jinja2_handler.py b/unit_tests/core/test_jinja2_handler.py index ddc6f9ac0..44fff81d8 100644 --- a/unit_tests/core/test_jinja2_handler.py +++ b/unit_tests/core/test_jinja2_handler.py @@ -1,5 +1,3 @@ -import random - import pytest from django.contrib.gis.geos import Point from django.core.management import call_command @@ -9,7 +7,6 @@ action_by_direction, display_infos_panel, distance_to_acteur, - is_embedded, ) from qfdmo.models.acteur import ActeurType from unit_tests.qfdmo.acteur_factory import ActeurTypeFactory, DisplayedActeurFactory @@ -25,25 +22,6 @@ def django_db_setup(django_db_setup, django_db_blocker): ) -class TestIsIframe: - def test_is_embedded_false(self): - request = HttpRequest() - - request.GET = {} - assert is_embedded(request) is False - - def test_is_embedded_true(self): - request = HttpRequest() - - request.GET = {"iframe": str(random.randint(0, 10))} - - assert is_embedded(request) is True - - request.GET = {"iframe": "anything"} - - assert is_embedded(request) is True - - class TestActionByDirection: @pytest.mark.django_db def test_action_by_direction_default(self): diff --git a/unit_tests/qfdmo/test_acteur.py b/unit_tests/qfdmo/test_acteur.py index b333763cf..f58a274b2 100644 --- a/unit_tests/qfdmo/test_acteur.py +++ b/unit_tests/qfdmo/test_acteur.py @@ -346,7 +346,7 @@ def test_acteur_actions_multiple(self, displayed_acteur): ), ) - assert displayed_acteur.get_acteur_services() == [ + assert displayed_acteur.acteur_services_libelles_alpha_sorted == [ "Atelier pour réparer soi-même", "Par un professionnel", ] @@ -397,7 +397,8 @@ def test_basic(self): "afficher": True, "description": None, "order": action.order, - "couleur": "yellow-tournesol", + "couleur": "#C3992A", + "couleur_claire": "#C3992A", "icon": None, "groupe_action": None, } @@ -422,7 +423,8 @@ def test_with_direction(self): "afficher": True, "description": None, "order": action.order, - "couleur": "yellow-tournesol", + "couleur": "#C3992A", + "couleur_claire": "#C3992A", "icon": None, "groupe_action": None, } diff --git a/unit_tests/qfdmo/test_addresses_view.py b/unit_tests/qfdmo/test_addresses_view.py index b479681ff..7cafe3968 100644 --- a/unit_tests/qfdmo/test_addresses_view.py +++ b/unit_tests/qfdmo/test_addresses_view.py @@ -2,9 +2,52 @@ from django.http import HttpRequest from qfdmo.views.adresses import CarteView +from unit_tests.core.test_utils import query_dict_from -class TestAdessesViewGetActionList: +@pytest.mark.django_db +class TestAdresseViewMixins: + def test_iframe_mixin_is_carte(self): + request = HttpRequest() + request.GET = query_dict_from( + { + "carte": "coucou", + } + ) + adresses_view = CarteView() + adresses_view.setup(request) + assert adresses_view.is_carte + assert adresses_view.get_context_data()["is_carte"] + assert adresses_view.is_embedded + assert adresses_view.get_context_data()["is_embedded"] + + def test_iframe_mixin_is_iframe(self): + request = HttpRequest() + request.GET = query_dict_from( + { + "iframe": "coucou", + } + ) + adresses_view = CarteView() + adresses_view.setup(request) + assert adresses_view.is_iframe + assert adresses_view.get_context_data()["is_iframe"] + assert adresses_view.is_embedded + assert adresses_view.get_context_data()["is_embedded"] + + def test_digital_mixin(self): + request = HttpRequest() + request.GET = query_dict_from( + { + "digital": "1", + } + ) + adresses_view = CarteView() + adresses_view.setup(request) + assert adresses_view.get_context_data()["is_digital"] + + +class TestAdressesViewGetActionList: @pytest.mark.parametrize( "params,action_list", [ From d0de27aeefab01a049f25780d4bf3814230be463 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Thu, 31 Oct 2024 22:03:30 +0100 Subject: [PATCH 037/109] wip --- .../_addresses_partials/filters/_modal.html | 9 +++++---- jinja2/qfdmo/carte/header.html | 6 +++++- jinja2/qfdmo/formulaire/header.html | 2 +- jinja2/qfdmo/shared/_main.html | 19 ++++++++----------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/jinja2/qfdmo/_addresses_partials/filters/_modal.html b/jinja2/qfdmo/_addresses_partials/filters/_modal.html index 318be38b1..b88e92122 100644 --- a/jinja2/qfdmo/_addresses_partials/filters/_modal.html +++ b/jinja2/qfdmo/_addresses_partials/filters/_modal.html @@ -1,16 +1,17 @@
{# Recherche adresse #} -
+
{% include 'qfdmo/_addresses_partials/adresse_input_form.html' %}
diff --git a/jinja2/qfdmo/formulaire/header.html b/jinja2/qfdmo/formulaire/header.html index 10f929406..5334ce212 100644 --- a/jinja2/qfdmo/formulaire/header.html +++ b/jinja2/qfdmo/formulaire/header.html @@ -1,4 +1,4 @@ -
+
{# Panel «Filtres avancés» #} {% include 'qfdmo/formulaire/advanced_filters.html' %} diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html index f58b5e5f5..c4ef2fc80 100644 --- a/jinja2/qfdmo/shared/_main.html +++ b/jinja2/qfdmo/shared/_main.html @@ -16,16 +16,15 @@ ss-cat-object-autocomplete:formSubmit->search-solution-form#advancedSubmit" class=" qfdmo-h-full + qfdmo-m-0 qfdmo-flex qfdmo-flex-col qfdmo-flex-auto - qfdmo-relative - qfdmo-p-1v - " + qfdmo-relative" >
{% block content_header %} {% endblock content_header %} @@ -39,17 +38,16 @@ They need to match the css variables used for .grid-map selector in qfdmo.css #}
{% block result %} Date: Thu, 31 Oct 2024 22:29:16 +0100 Subject: [PATCH 038/109] Add sitemap --- .secrets.baseline | 4 ++-- core/settings.py | 1 + core/urls.py | 29 +++++++++++++++++++++++++++++ qfdmo/models/acteur.py | 3 +++ qfdmo/views/adresses.py | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index ffb55928b..3e279fbb8 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -151,7 +151,7 @@ "filename": "core/settings.py", "hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9", "is_verified": false, - "line_number": 204 + "line_number": 205 } ], "docker-compose.yml": [ @@ -207,5 +207,5 @@ } ] }, - "generated_at": "2024-10-31T20:01:37Z" + "generated_at": "2024-10-31T21:28:37Z" } diff --git a/core/settings.py b/core/settings.py index 29bcd6c97..baabe6757 100644 --- a/core/settings.py +++ b/core/settings.py @@ -42,6 +42,7 @@ "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", + "django.contrib.sitemaps", "whitenoise.runserver_nostatic", "django.contrib.staticfiles", "django.contrib.gis", diff --git a/core/urls.py b/core/urls.py index 6f2e5722f..17939df22 100644 --- a/core/urls.py +++ b/core/urls.py @@ -17,14 +17,43 @@ from django.conf import settings from django.contrib import admin +from django.contrib.sitemaps import GenericSitemap +from django.contrib.sitemaps import views as sitemaps_views from django.urls import include, path +from qfdmo.models.acteur import DisplayedActeur + from .api import api +info_dict = { + "queryset": DisplayedActeur.objects.all(), + "date_field": "modifie_le", +} + + +class PaginatedSitemap(GenericSitemap): + limit = 500 + + +sitemaps = {"items": PaginatedSitemap(info_dict, priority=1.0)} + + urlpatterns = [ path("admin/", admin.site.urls), path("api/", api.urls), path("explorer/", include("explorer.urls")), + path( + "sitemap.xml", + sitemaps_views.index, + {"sitemaps": sitemaps}, + name="django.contrib.sitemaps.views.index", + ), + path( + "sitemap-
.xml", + sitemaps_views.sitemap, + {"sitemaps": sitemaps}, + name="django.contrib.sitemaps.views.sitemap", + ), path("", include(("qfdmo.urls", "qfdmo"), namespace="qfdmo")), ] diff --git a/qfdmo/models/acteur.py b/qfdmo/models/acteur.py index 2e69ad615..215e53984 100644 --- a/qfdmo/models/acteur.py +++ b/qfdmo/models/acteur.py @@ -599,6 +599,9 @@ class Meta: related_name="displayed_acteurs", ) + def get_absolute_url(self): + return reverse("qfdmo:acteur-detail", args=[self.identifiant_unique]) + def acteur_actions(self, direction=None): ps_action_ids = list( {ps.action_id for ps in self.proposition_services.all()} # type: ignore diff --git a/qfdmo/views/adresses.py b/qfdmo/views/adresses.py index b73cf44d5..2303a7968 100644 --- a/qfdmo/views/adresses.py +++ b/qfdmo/views/adresses.py @@ -654,6 +654,7 @@ def acteur_detail(request, identifiant_unique): "display_sources_panel": bool( displayed_acteur.sources.filter(afficher=True).count() ), + "is_embedded": False, } if latitude and longitude and not displayed_acteur.is_digital: From a4377b0e4e65c3e0cbb7ab6f058bc9b7f5ef7416 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Fri, 1 Nov 2024 11:44:01 +0100 Subject: [PATCH 039/109] wip --- jinja2/qfdmo/acteur.html | 4 +-- jinja2/qfdmo/acteur/tabs/_section.html | 2 +- .../qfdmo/acteur/tabs/sections/telephone.html | 7 +++-- jinja2/qfdmo/carte/panels/acteur_detail.html | 4 +-- jinja2/qfdmo/shared/_main.html | 27 +++++++------------ static/to_compile/entrypoints/qfdmo.css | 14 +++++++++- .../src/search_solution_form_controller.ts | 23 +++++++++------- 7 files changed, 42 insertions(+), 39 deletions(-) diff --git a/jinja2/qfdmo/acteur.html b/jinja2/qfdmo/acteur.html index 53223b2f4..9ad562122 100644 --- a/jinja2/qfdmo/acteur.html +++ b/jinja2/qfdmo/acteur.html @@ -1,8 +1,7 @@ {% extends base_template %} {% block content %} -
-
+
@@ -21,6 +20,5 @@

{{ object.nom }}

{% include "qfdmo/acteur/_tabs.html" %}
-
{% endblock content %} diff --git a/jinja2/qfdmo/acteur/tabs/_section.html b/jinja2/qfdmo/acteur/tabs/_section.html index 5b82167b2..2077669d4 100644 --- a/jinja2/qfdmo/acteur/tabs/_section.html +++ b/jinja2/qfdmo/acteur/tabs/_section.html @@ -1,5 +1,5 @@
-

+

{% block title %} {% endblock title %}

diff --git a/jinja2/qfdmo/acteur/tabs/sections/telephone.html b/jinja2/qfdmo/acteur/tabs/sections/telephone.html index 23f2561cc..5c56e756d 100644 --- a/jinja2/qfdmo/acteur/tabs/sections/telephone.html +++ b/jinja2/qfdmo/acteur/tabs/sections/telephone.html @@ -1,10 +1,9 @@ {% extends "qfdmo/acteur/tabs/_section.html" %} -{% block title %}{% endblock title %} +{% block title %}Téléphone{% endblock title %} +{% block title_classes %}qfdmo-sr-only{% endblock title_classes %} -{% block wrapper_attrs %} -class="max-md:qfdmo-hidden" -{% endblock %} +{% block wrapper_attrs %}class="max-md:qfdmo-hidden"{% endblock %} {% block content %}

diff --git a/jinja2/qfdmo/carte/panels/acteur_detail.html b/jinja2/qfdmo/carte/panels/acteur_detail.html index 6e5d72b65..c3b570da9 100644 --- a/jinja2/qfdmo/carte/panels/acteur_detail.html +++ b/jinja2/qfdmo/carte/panels/acteur_detail.html @@ -4,12 +4,12 @@ class="md:qfdmo-hidden qfdmo-rounded-full qfdmo-w-12w qfdmo-h-1v qfdmo-bg-[#DFDFDF] qfdmo-my-2w qfdmo-mx-auto" > {# Content #} -

+
{# Close button #} - +
diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html index c4ef2fc80..ecf005bd2 100644 --- a/jinja2/qfdmo/shared/_main.html +++ b/jinja2/qfdmo/shared/_main.html @@ -72,33 +72,24 @@ {{ form.bounding_box }} {% endblock form %}
+ {# Part of this tag style is defined in qfdmo.css because it would have been a bit unreadable as tailwind classes #} diff --git a/static/to_compile/entrypoints/qfdmo.css b/static/to_compile/entrypoints/qfdmo.css index f2dca65ba..9ee14a600 100644 --- a/static/to_compile/entrypoints/qfdmo.css +++ b/static/to_compile/entrypoints/qfdmo.css @@ -270,27 +270,39 @@ DSFR customization for tabs .map-grid { --footer-height: 0; + --sidebar-width: 0; --header-height: 120px; @apply qfdmo-min-h-screen md:qfdmo-grid qfdmo-gap-0; @apply qfdmo-grid-flow-row-dense; - grid-template-columns: 1fr auto; + @apply qfdmo-transition-[grid-template-columns] qfdmo-ease-in; + grid-template-columns: auto var(--sidebar-width); grid-template-rows: var(--header-height) 1.5fr var(--footer-height); grid-template-areas: "header header" "map detail" "footer footer"; + + &:has(> aside[aria-hidden="false"]) { + @apply qfdmo-ease-out; + --sidebar-width: 400px; + } + > aside { grid-area: detail; } + > footer { grid-area: footer; } + > header { grid-area: header; } + > main { grid-area: map; } + .formulaire & { --footer-height: 100px; --header-height: 135px; diff --git a/static/to_compile/src/search_solution_form_controller.ts b/static/to_compile/src/search_solution_form_controller.ts index 73e0e2924..8db9de628 100644 --- a/static/to_compile/src/search_solution_form_controller.ts +++ b/static/to_compile/src/search_solution_form_controller.ts @@ -177,7 +177,6 @@ export default class extends Controller { } #hideAddressesPanel() { - // this.backToSearchPanelTarget.classList.add("qfdmo-h-0", "qfdmo-invisible") this.backToSearchPanelTarget.dataset.visible = "false" this.addressesPanelTarget.dataset.visible = "false" } @@ -193,24 +192,28 @@ export default class extends Controller { this.scrollToContent() } - showActeurDetailsPanel() { - this.acteurDetailsPanelTarget.dataset.visible = "true" - this.acteurDetailsPanelTarget.scrollIntoView() - } - updateBboxInput(event) { this.bboxTarget.value = JSON.stringify(event.detail) } + #showActeurDetailsPanel() { + if (this.acteurDetailsPanelTarget.ariaHidden !== "false") { + this.acteurDetailsPanelTarget.ariaHidden = "false" + } + + this.acteurDetailsPanelTarget.dataset.exitAnimationEnded = "false" + this.acteurDetailsPanelTarget.scrollIntoView() + } + hideActeurDetailsPanel() { document .querySelector("[aria-controls=acteurDetailsPanel][aria-expanded=true]") ?.setAttribute("aria-expanded", "false") - this.acteurDetailsPanelTarget.dataset.visible = "exit" + this.acteurDetailsPanelTarget.ariaHidden = "true" this.acteurDetailsPanelTarget.addEventListener( "animationend", () => { - this.acteurDetailsPanelTarget.dataset.visible = "false" + this.acteurDetailsPanelTarget.dataset.exitAnimationEnded= "true" }, { once: true }, ) @@ -224,7 +227,7 @@ export default class extends Controller { .querySelector("[aria-controls='acteurDetailsPanel'][aria-expanded='true']") ?.setAttribute("aria-expanded", "false") event.currentTarget.setAttribute("aria-expanded", "true") - this.showActeurDetailsPanel() + this.#showActeurDetailsPanel() } displayActeur(identifiantUnique) { @@ -240,7 +243,7 @@ export default class extends Controller { } const acteurDetailPath = `/adresse/${identifiantUnique}?${params.toString()}` Turbo.visit(acteurDetailPath, { frame: "acteur-detail" }) - this.showActeurDetailsPanel() + this.#showActeurDetailsPanel() } displayActionList() { From 620412d2dfe0ac4815cfaa71f282dc76b3b9778e Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Fri, 1 Nov 2024 11:47:24 +0100 Subject: [PATCH 040/109] wip --- jinja2/qfdmo/carte/panels/acteur_detail.html | 2 +- jinja2/qfdmo/shared/_main.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jinja2/qfdmo/carte/panels/acteur_detail.html b/jinja2/qfdmo/carte/panels/acteur_detail.html index c3b570da9..31fbfa6b8 100644 --- a/jinja2/qfdmo/carte/panels/acteur_detail.html +++ b/jinja2/qfdmo/carte/panels/acteur_detail.html @@ -11,5 +11,5 @@ data-action="click->search-solution-form#hideActeurDetailsPanel" > - +
diff --git a/jinja2/qfdmo/shared/_main.html b/jinja2/qfdmo/shared/_main.html index ecf005bd2..035e4b81c 100644 --- a/jinja2/qfdmo/shared/_main.html +++ b/jinja2/qfdmo/shared/_main.html @@ -84,7 +84,7 @@ qfdmo-px-2w aria-[hidden=true]:max-md:qfdmo-animate-out aria-[hidden=true]:max-md:qfdmo-slide-out-to-bottom - aria-[hidden=true]:data-[exit-animation-ended=true]:qqfdmo-hidden + aria-[hidden=true]:data-[exit-animation-ended=true]:qfdmo-hidden " tabindex="0" id="acteurDetailsPanel" From 5baea3a643e33f43bc9a946028a6a2a477b43c05 Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Fri, 1 Nov 2024 13:17:20 +0100 Subject: [PATCH 041/109] wip --- .secrets.baseline | 4 ++-- jinja2/layout/base.html | 1 + .../_addresses_partials/filters/_modal.html | 4 ++-- jinja2/qfdmo/carte.html | 15 ++++++++------ jinja2/qfdmo/carte/panels/acteur_detail.html | 4 ++-- jinja2/qfdmo/shared/_main.html | 20 +++++++++++++------ jinja2/qfdmo/shared/_map_container.html | 2 +- jinja2/qfdmo/shared/_search_in_zone.html | 2 +- static/to_compile/entrypoints/qfdmo.css | 14 +++++++++++++ 9 files changed, 46 insertions(+), 20 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 3e279fbb8..9b59d075b 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -178,7 +178,7 @@ "filename": "jinja2/layout/base.html", "hashed_secret": "057dece35d736a3ae1e710a9cba3f080bd101cde", "is_verified": false, - "line_number": 73 + "line_number": 74 } ], "static/to_compile/src/analytics.ts": [ @@ -207,5 +207,5 @@ } ] }, - "generated_at": "2024-10-31T21:28:37Z" + "generated_at": "2024-11-01T12:17:15Z" } diff --git a/jinja2/layout/base.html b/jinja2/layout/base.html index 3528de7d1..90f5c1a46 100644 --- a/jinja2/layout/base.html +++ b/jinja2/layout/base.html @@ -66,6 +66,7 @@

Une mise à jour de votre navigateur est nécessaire {% endblock %} {% endif %} + {% block modals %}{% endblock modals %} {% block js %} {% if is_embedded %} {% else %} -