From c18c0aa0f5a52234e43f43f9b2f3dfb0f1e190e7 Mon Sep 17 00:00:00 2001 From: PY Date: Fri, 4 Oct 2024 10:03:31 +0200 Subject: [PATCH] separate haie and amenagement --- envergo/moulinette/models.py | 10 +++++++++ envergo/moulinette/views.py | 11 ++++++---- envergo/pages/views.py | 2 +- .../moulinette/_form_scripts.html | 12 ++++++++++ .../moulinette/_form_styles.html | 0 .../amenagement/moulinette/home.html | 10 +++++++++ .../amenagement/moulinette/result.html | 4 ++++ .../pages/geometricians.html | 17 +++----------- envergo/templates/amenagement/pages/home.html | 17 +++----------- envergo/templates/haie/moulinette/home.html | 8 +++++++ envergo/templates/moulinette/base.html | 22 ------------------- 11 files changed, 58 insertions(+), 55 deletions(-) rename envergo/templates/{ => amenagement}/moulinette/_form_scripts.html (61%) rename envergo/templates/{ => amenagement}/moulinette/_form_styles.html (100%) create mode 100644 envergo/templates/amenagement/moulinette/home.html rename envergo/templates/{ => amenagement}/pages/geometricians.html (91%) create mode 100644 envergo/templates/haie/moulinette/home.html diff --git a/envergo/moulinette/models.py b/envergo/moulinette/models.py index 5925aa7c6..a74e1a70b 100644 --- a/envergo/moulinette/models.py +++ b/envergo/moulinette/models.py @@ -863,6 +863,14 @@ def get_template(self, template_key): return self.templates.get(template_key, None) + @classmethod + def get_home_template(cls): + """Return the template to display the result page.""" + + if not hasattr(cls, "home_template"): + raise AttributeError("No result template found.") + return cls.home_template + def get_result_template(self): """Return the template to display the result page.""" @@ -1151,6 +1159,7 @@ def get_extra_context(cls, request): class MoulinetteAmenagement(Moulinette): REGULATIONS = ["loi_sur_leau", "natura2000", "eval_env", "sage"] + home_template = "amenagement/moulinette/home.html" result_template = "amenagement/moulinette/result.html" debug_result_template = "amenagement/moulinette/result_debug.html" form_template = "amenagement/moulinette/form.html" @@ -1378,6 +1387,7 @@ def get_triage_params(cls): class MoulinetteHaie(Moulinette): REGULATIONS = ["conditionnalite_pac", "dep"] + home_template = "haie/moulinette/home.html" result_template = "haie/moulinette/result.html" debug_result_template = "haie/moulinette/result.html" form_template = "haie/moulinette/form.html" diff --git a/envergo/moulinette/views.py b/envergo/moulinette/views.py index bbc746fbe..9fd923389 100644 --- a/envergo/moulinette/views.py +++ b/envergo/moulinette/views.py @@ -295,7 +295,9 @@ def log_moulinette_event(self, moulinette, **kwargs): class MoulinetteHome(MoulinetteMixin, FormView): - template_name = "moulinette/home.html" + def get_template_names(self): + MoulinetteClass = get_moulinette_class_from_site(self.request.site) + return MoulinetteClass.get_home_template() def get(self, request, *args, **kwargs): context = self.get_context_data() @@ -322,17 +324,18 @@ def get_template_names(self): is_admin = self.request.user.is_staff if moulinette is None: - template_name = "moulinette/home.html" + MoulinetteClass = get_moulinette_class_from_site(self.request.site) + template_name = MoulinetteClass.get_home_template() elif is_debug: template_name = moulinette.get_debug_result_template() elif is_edit: - template_name = "moulinette/home.html" + template_name = moulinette.get_home_template() elif not moulinette.has_config(): template_name = "moulinette/result_non_disponible.html" elif not (moulinette.is_evaluation_available() or is_admin): template_name = "moulinette/result_available_soon.html" elif moulinette.has_missing_data(): - template_name = "moulinette/home.html" + template_name = moulinette.get_home_template() else: template_name = moulinette.get_result_template() diff --git a/envergo/pages/views.py b/envergo/pages/views.py index 6726de2da..c81274aff 100644 --- a/envergo/pages/views.py +++ b/envergo/pages/views.py @@ -24,7 +24,7 @@ class HomeHaieView(MoulinetteMixin, FormView): class GeometriciansView(MoulinetteMixin, FormView): - template_name = "pages/geometricians.html" + template_name = "amenagement/pages/geometricians.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/envergo/templates/moulinette/_form_scripts.html b/envergo/templates/amenagement/moulinette/_form_scripts.html similarity index 61% rename from envergo/templates/moulinette/_form_scripts.html rename to envergo/templates/amenagement/moulinette/_form_scripts.html index 409d4f3ce..d3307c2a1 100644 --- a/envergo/templates/moulinette/_form_scripts.html +++ b/envergo/templates/amenagement/moulinette/_form_scripts.html @@ -1,5 +1,17 @@ {% load static l10n %} + + diff --git a/envergo/templates/moulinette/_form_styles.html b/envergo/templates/amenagement/moulinette/_form_styles.html similarity index 100% rename from envergo/templates/moulinette/_form_styles.html rename to envergo/templates/amenagement/moulinette/_form_styles.html diff --git a/envergo/templates/amenagement/moulinette/home.html b/envergo/templates/amenagement/moulinette/home.html new file mode 100644 index 000000000..7aaa8d008 --- /dev/null +++ b/envergo/templates/amenagement/moulinette/home.html @@ -0,0 +1,10 @@ +{% extends "moulinette/home.html" %} + +{% load l10n %} + +{% block extra_css %} + {% include 'amenagement/moulinette/_form_styles.html' %} +{% endblock %} +{% block extra_js %} + {% include 'amenagement/moulinette/_form_scripts.html' %} +{% endblock %} diff --git a/envergo/templates/amenagement/moulinette/result.html b/envergo/templates/amenagement/moulinette/result.html index 3c2c7e18e..e90558760 100644 --- a/envergo/templates/amenagement/moulinette/result.html +++ b/envergo/templates/amenagement/moulinette/result.html @@ -94,6 +94,10 @@

{% include 'moulinette/_actions_banner.html' %} {% endblock %} +{% block extra_css %} + {% include 'amenagement/moulinette/_form_styles.html' %} +{% endblock %} + {% block extra_js %} {{ block.super }} - {% include 'moulinette/_form_scripts.html' %} + + {% include 'amenagement/moulinette/_form_scripts.html' %} {% endblock %} diff --git a/envergo/templates/amenagement/pages/home.html b/envergo/templates/amenagement/pages/home.html index eff22c604..c1e029008 100644 --- a/envergo/templates/amenagement/pages/home.html +++ b/envergo/templates/amenagement/pages/home.html @@ -169,22 +169,11 @@

{% endblock %} {% block extra_css %} - {% include 'moulinette/_form_styles.html' %} + {% include 'amenagement/moulinette/_form_styles.html' %} {% endblock %} {% block extra_js %} - - {% include 'moulinette/_form_scripts.html' %} + + {% include 'amenagement/moulinette/_form_scripts.html' %} {% endblock %} diff --git a/envergo/templates/haie/moulinette/home.html b/envergo/templates/haie/moulinette/home.html new file mode 100644 index 000000000..d93cd54f7 --- /dev/null +++ b/envergo/templates/haie/moulinette/home.html @@ -0,0 +1,8 @@ +{% extends "moulinette/home.html" %} + +{% load static %} + +{% block extra_js %} + + +{% endblock %} diff --git a/envergo/templates/moulinette/base.html b/envergo/templates/moulinette/base.html index ab6571bcb..549a69eb4 100644 --- a/envergo/templates/moulinette/base.html +++ b/envergo/templates/moulinette/base.html @@ -1,25 +1,3 @@ {% extends 'base.html' %} -{% load evaluations static l10n %} - {% block title %}Simulation réglementaire du projet{% endblock %} - -{% block extra_css %} - {% include 'moulinette/_form_styles.html' %} -{% endblock %} - -{% block extra_js %} - - {% include 'moulinette/_form_scripts.html' %} - -{% endblock %}