From a5d3afd375e0232f51a9525f54a455b8b2529090 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 28 Nov 2023 14:50:39 +0100 Subject: 🐛 Admin Profile type - fix "default center" field (refs #5675) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog/en/changelog_2022-06-15.md | 4 +++- changelog/fr/changelog_2023-01-25.md | 4 +++- ishtar_common/admin.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index 737967018..df6e0630b 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -3,7 +3,9 @@ v4.0.67 - 2023-11-28 ### Bug fixes ### - GIS form - remove "timestamp" fields (#5673) -- Instance Profile - fix migration: provide default for complete id and cached label (#5674) +- Instance Profile: + - fix migration: provide default for complete id and cached label (#5674) + - fix "default center" field (#5675) v4.0.66 - 2023-11-22 -------------------- diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index 16767cca8..4b822e556 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -3,7 +3,9 @@ v4.0.67 - 2023-11-28 ### Corrections de dysfonctionnements ### - Formulaire SIG - suppression des champs "horodatage" (#5673) -- Profile d'instance - correction de migration de base de donnĂ©es : valeur par dĂ©faut pour l'identifiant complet et le libellĂ© mise en cache (#5674) +- Profile d'instance : + - correction de migration de base de donnĂ©es : valeur par dĂ©faut pour l'identifiant complet et le libellĂ© mise en cache (#5674) + - correction du champ "centre par dĂ©faut" (#5675) v4.0.66 - 2023-11-22 -------------------- diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 58ef286e1..ae4a3227b 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -624,6 +624,23 @@ class IshtarSiteProfileAdmin(admin.ModelAdmin): }), ) + class Media: + js = ( + "ol/ol.js", + "ol-layerswitcher/ol-layerswitcher.js", + "admin/js/jquery.init.js", + "js/ishtar-map.js", + ) + + def save_model(self, request, obj, form, change): + # reverse... geo + form.cleaned_data["default_center"] = form.cleaned_data["default_center"].transform(4326) + point = form.cleaned_data["default_center"] + if point: + form.cleaned_data["default_center"].x = point.y + form.cleaned_data["default_center"].y = point.x + super().save_model(request, obj, form, change) + admin_site.register(models.IshtarSiteProfile, IshtarSiteProfileAdmin) -- cgit v1.2.3