diff --git a/config/settings.py b/config/settings.py index 881ad335..19e5f794 100644 --- a/config/settings.py +++ b/config/settings.py @@ -53,6 +53,7 @@ "wagtail.search", "wagtail", "wagtailmenus", + "wagtail_modeladmin", "taggit", "django.contrib.auth", "django.contrib.contenttypes", diff --git a/content_manager/migrations/0009_cmsdsfrconfig_footer_theme_modale_and_more.py b/content_manager/migrations/0009_cmsdsfrconfig_footer_theme_modale_and_more.py new file mode 100644 index 00000000..40500453 --- /dev/null +++ b/content_manager/migrations/0009_cmsdsfrconfig_footer_theme_modale_and_more.py @@ -0,0 +1,444 @@ +# Generated by Django 4.2.7 on 2023-11-27 16:21 + +import wagtail.blocks +import wagtail.documents.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("content_manager", "0008_alter_contentpage_body"), + ] + + operations = [ + migrations.AddField( + model_name="cmsdsfrconfig", + name="footer_theme_modale", + field=models.BooleanField(default=False, verbose_name="Choix du thème clair/sombre"), + ), + migrations.AlterField( + model_name="contentpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "hero", + wagtail.blocks.StructBlock( + [ + ("bg_image", wagtail.images.blocks.ImageChooserBlock(label="Image d'arrière plan")), + ( + "bg_color", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "La couleur n'est pas correcte, le format doit être #fff ou #f5f5fe" + }, + label="Couleur d'arrière plan au format hexa (Ex: #f5f5fe)", + regex="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$", + required=False, + ), + ), + ("title", wagtail.blocks.CharBlock(label="Titre")), + ("text", wagtail.blocks.CharBlock(label="Texte", required=False)), + ("cta_label", wagtail.blocks.CharBlock(label="Texte du bouton", required=False)), + ("cta_link", wagtail.blocks.URLBlock(label="Lien du bouton", required=False)), + ], + label="Section promotionnelle", + ), + ), + ( + "title", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre")), + ("large", wagtail.blocks.BooleanBlock(label="Large", required=False)), + ], + label="Titre de page", + ), + ), + ("paragraph", wagtail.blocks.RichTextBlock(label="Texte avec mise en forme")), + ("paragraphlarge", wagtail.blocks.RichTextBlock(label="Texte avec mise en forme (large)")), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre", required=False)), + ("image", wagtail.images.blocks.ImageChooserBlock(label="Illustration")), + ( + "alt", + wagtail.blocks.CharBlock( + label="Texte alternatif (description textuelle de l'image)", required=False + ), + ), + ("caption", wagtail.blocks.CharBlock(label="Légende", required=False)), + ("url", wagtail.blocks.URLBlock(label="Lien", required=False)), + ] + ), + ), + ( + "imageandtext", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock(label="Illustration (à gauche)")), + ( + "image_ratio", + wagtail.blocks.ChoiceBlock( + choices=[("3", "3/12"), ("5", "5/12"), ("6", "6/12")], + label="Largeur de l'image", + ), + ), + ("text", wagtail.blocks.RichTextBlock(label="Texte avec mise en forme (à droite)")), + ( + "link_label", + wagtail.blocks.CharBlock( + help_text="Le lien apparait en bas du bloc de droite, avec une flèche", + label="Titre du lien", + required=False, + ), + ), + ("link_url", wagtail.blocks.URLBlock(label="Lien", required=False)), + ], + label="Bloc image à gauche et texte à droite", + ), + ), + ( + "alert", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre du message", required=False)), + ("description", wagtail.blocks.TextBlock(label="Texte du message", required=False)), + ( + "level", + wagtail.blocks.ChoiceBlock( + choices=[ + ("error", "Erreur"), + ("success", "Succès"), + ("info", "Information"), + ("warning", "Attention"), + ], + label="Type de message", + ), + ), + ], + label="Message d'alerte", + ), + ), + ( + "callout", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre de la mise en vant", required=False)), + ("text", wagtail.blocks.TextBlock(label="Texte mis en avant", required=False)), + ( + "heading_tag", + wagtail.blocks.ChoiceBlock( + choices=[ + ("h2", "En-tête 2"), + ("h3", "En-tête 3"), + ("h4", "En-tête 4"), + ("h5", "En-tête 5"), + ("h6", "En-tête 6"), + ("p", "Paragraphe"), + ], + help_text="À adapter à la structure de la page. Par défaut en-tête 3.", + label="Niveau de titre", + ), + ), + ], + label="Texte mise en avant", + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + label="Illustration (à gauche)", required=False + ), + ), + ("quote", wagtail.blocks.CharBlock(label="Citation")), + ("author_name", wagtail.blocks.CharBlock(label="Nom de l'auteur")), + ("author_title", wagtail.blocks.CharBlock(label="Titre de l'auteur")), + ], + label="Citation", + ), + ), + ( + "video", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre", required=False)), + ("caption", wagtail.blocks.CharBlock(label="Légende")), + ( + "url", + wagtail.blocks.URLBlock( + help_text="URL au format 'embed' (Ex. : https://www.youtube.com/embed/gLzXOViPX-0)", + label="Lien de la vidéo", + ), + ), + ], + label="Vidéo", + ), + ), + ( + "multicolumns", + wagtail.blocks.StructBlock( + [ + ( + "bg_image", + wagtail.images.blocks.ImageChooserBlock( + label="Image d'arrière plan", required=False + ), + ), + ( + "bg_color", + wagtail.blocks.RegexBlock( + error_messages={ + "invalid": "La couleur n'est pas correcte, le format doit être #fff ou #f5f5fe" + }, + label="Couleur d'arrière plan au format hexa (Ex: #f5f5fe)", + regex="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$", + required=False, + ), + ), + ("title", wagtail.blocks.CharBlock(label="Titre", required=False)), + ( + "columns", + wagtail.blocks.StreamBlock( + [ + ("text", wagtail.blocks.RichTextBlock(label="Texte avec mise en forme")), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock(label="Titre", required=False), + ), + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + label="Illustration" + ), + ), + ( + "alt", + wagtail.blocks.CharBlock( + label="Texte alternatif (description textuelle de l'image)", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock(label="Légende", required=False), + ), + ("url", wagtail.blocks.URLBlock(label="Lien", required=False)), + ], + label="Image", + ), + ), + ( + "video", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock(label="Titre", required=False), + ), + ("caption", wagtail.blocks.CharBlock(label="Légende")), + ( + "url", + wagtail.blocks.URLBlock( + help_text="URL au format 'embed' (Ex. : https://www.youtube.com/embed/gLzXOViPX-0)", + label="Lien de la vidéo", + ), + ), + ], + label="Vidéo", + ), + ), + ( + "card", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre")), + ("description", wagtail.blocks.TextBlock(label="Texte")), + ( + "image", + wagtail.images.blocks.ImageChooserBlock(label="Image"), + ), + ("url", wagtail.blocks.URLBlock(label="Lien", required=False)), + ( + "document", + wagtail.documents.blocks.DocumentChooserBlock( + help_text="Sélectionnez un document pour rendre la carte cliquable vers celui ci (si le champ `Lien` n'est pas renseigné).", + label="ou Document", + required=False, + ), + ), + ], + label="Carte", + ), + ), + ( + "quote", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + label="Illustration (à gauche)", required=False + ), + ), + ("quote", wagtail.blocks.CharBlock(label="Citation")), + ( + "author_name", + wagtail.blocks.CharBlock(label="Nom de l'auteur"), + ), + ( + "author_title", + wagtail.blocks.CharBlock(label="Titre de l'auteur"), + ), + ], + label="Citation", + ), + ), + ( + "text_cta", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.RichTextBlock( + label="Texte avec mise en forme", required=False + ), + ), + ( + "cta_label", + wagtail.blocks.CharBlock( + help_text="Le lien apparait comme un bouton sous le bloc de texte", + label="Titre de l'appel à l'action", + required=False, + ), + ), + ( + "cta_url", + wagtail.blocks.CharBlock(label="Lien", required=False), + ), + ], + label="Texte et appel à l'action", + ), + ), + ( + "iframe", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Accessibilité : Le titre doit décrire, de façon claire et concise, le contenu embarqué.", + label="Titre", + ), + ), + ( + "url", + wagtail.blocks.URLBlock( + help_text="Exemple pour Tally : https://tally.so/embed/w2jMRa", + label="Lien du cadre intégré", + ), + ), + ( + "height", + wagtail.blocks.IntegerBlock(label="Hauteur en pixels"), + ), + ], + label="Cadre intégré", + ), + ), + ], + label="Multi-colonnes", + ), + ), + ], + label="Multi-colonnes", + ), + ), + ( + "accordions", + wagtail.blocks.StreamBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre")), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre")), + ("content", wagtail.blocks.RichTextBlock(label="Contenu")), + ], + label="Accordéon", + max_num=15, + min_num=1, + ), + ), + ], + label="Accordéons", + ), + ), + ( + "stepper", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre")), + ("total", wagtail.blocks.IntegerBlock(label="Nombre d'étape")), + ("current", wagtail.blocks.IntegerBlock(label="Étape en cours")), + ( + "steps", + wagtail.blocks.StreamBlock( + [ + ( + "step", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titre de l'étape")), + ("detail", wagtail.blocks.TextBlock(label="Détail")), + ], + label="Étape", + ), + ) + ], + label="Les étapes", + ), + ), + ], + label="Étapes", + ), + ), + ( + "separator", + wagtail.blocks.StructBlock( + [ + ( + "top_margin", + wagtail.blocks.IntegerBlock( + default=3, label="Espacement au dessus", max_value=15, min_value=0 + ), + ), + ( + "bottom_margin", + wagtail.blocks.IntegerBlock( + default=3, label="Espacement en dessous", max_value=15, min_value=0 + ), + ), + ], + label="Séparateur", + ), + ), + ], + blank=True, + use_json_field=True, + ), + ), + ] diff --git a/content_manager/migrations/0010_rename_footer_theme_modale_cmsdsfrconfig_theme_modale_button.py b/content_manager/migrations/0010_rename_footer_theme_modale_cmsdsfrconfig_theme_modale_button.py new file mode 100644 index 00000000..c0d2b031 --- /dev/null +++ b/content_manager/migrations/0010_rename_footer_theme_modale_cmsdsfrconfig_theme_modale_button.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.7 on 2023-11-27 16:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("content_manager", "0009_cmsdsfrconfig_footer_theme_modale_and_more"), + ] + + operations = [ + migrations.RenameField( + model_name="cmsdsfrconfig", + old_name="footer_theme_modale", + new_name="theme_modale_button", + ), + ] diff --git a/content_manager/models.py b/content_manager/models.py index 2dd29720..d9635725 100644 --- a/content_manager/models.py +++ b/content_manager/models.py @@ -108,7 +108,7 @@ class Meta: ] -@register_setting(icon="code") +@register_setting(icon="cog") class CmsDsfrConfig(BaseSiteSetting): class Meta: verbose_name = "Configuration du site" @@ -161,6 +161,8 @@ class Meta: blank=True, help_text="Balises HTML autorisés", ) + + theme_modale_button = models.BooleanField("Choix du thème clair/sombre", default=False) mourning = models.BooleanField("Mise en berne", default=False) panels = [ @@ -172,4 +174,5 @@ class Meta: FieldPanel("site_tagline"), FieldPanel("footer_description"), FieldPanel("mourning"), + FieldPanel("theme_modale_button"), ] diff --git a/poetry.lock b/poetry.lock index 47b4d891..2949ca25 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1596,6 +1596,24 @@ Willow = {version = ">=1.6.2,<1.7", extras = ["heif"]} docs = ["Sphinx (>=1.5.2)", "myst-parser (==0.18.1)", "pyenchant (>=3.1.1,<4)", "sphinx-autobuild (>=0.6.0)", "sphinx-copybutton (>=0.5,<1.0)", "sphinx-wagtail-theme (==6.1.1)", "sphinxcontrib-spelling (>=5.4.0,<6)"] testing = ["Jinja2 (>=3.0,<3.2)", "azure-mgmt-cdn (>=12.0,<13.0)", "azure-mgmt-frontdoor (>=1.0,<1.1)", "black (==22.3.0)", "boto3 (>=1.28,<2)", "coverage (>=3.7.0)", "curlylint (==0.13.1)", "django-pattern-library (>=0.7,<0.8)", "djhtml (==1.5.2)", "doc8 (==0.8.1)", "factory-boy (>=3.2)", "freezegun (>=0.3.8)", "polib (>=1.1,<2.0)", "python-dateutil (>=2.7)", "pytz (>=2014.7)", "ruff (==0.0.290)", "semgrep (==1.40.0)", "tblib (>=2.0,<3.0)"] +[[package]] +name = "wagtail-modeladmin" +version = "1.0.0" +description = "Add any model in your project to the Wagtail admin. Formerly wagtail.contrib.modeladmin." +optional = false +python-versions = ">=3.8" +files = [ + {file = "wagtail_modeladmin-1.0.0-py3-none-any.whl", hash = "sha256:0d92dd012e17dd5b5d5058792c8549594884c87da7ef794e8f1765bb245a5340"}, + {file = "wagtail_modeladmin-1.0.0.tar.gz", hash = "sha256:da545ba34747bff01c942b8306e20ac17d8a64d1873734cc8cf7303716af93fc"}, +] + +[package.dependencies] +Wagtail = ">=5.0" + +[package.extras] +docs = ["Sphinx (>=6.0)", "myst_parser (>=0.18.1,<1.0)", "pyenchant (>=3.1.1,<4)", "sphinx-autobuild (>=0.6.0)", "sphinx-wagtail-theme (==6.0.0)", "sphinx_copybutton (>=0.5)", "sphinxcontrib-spelling (>=8.0,<9.0)"] +testing = ["dj-database-url (>=2.0.0)", "pre-commit (<3.0)"] + [[package]] name = "wagtailmenus" version = "3.1.9" @@ -1650,4 +1668,4 @@ testing = ["Pillow (>=9.1.0,<11.0.0)", "Wand (>=0.6,<1.0)", "black (==22.3.0)", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "a60540e2441b750108f79bdb7b82ecbaa11da02f7bbb2f33f2885b6a34582439" +content-hash = "3d6e6cb1261e6245e15f6ebef5611688839ca1fe77033b06c951c7c75a95e8db" diff --git a/pyproject.toml b/pyproject.toml index d93321fe..a4413d7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ dj-static = "^0.0.6" wagtailmenus = "^3.1.9" boto3 = "^1.29.1" django-storages = "^1.14.2" +wagtail-modeladmin = "^1.0.0" [tool.poetry.group.dev.dependencies] diff --git a/templates/blocks/footer.html b/templates/blocks/footer.html index 0f1d06fc..019eff68 100644 --- a/templates/blocks/footer.html +++ b/templates/blocks/footer.html @@ -13,4 +13,11 @@ {% block footer_links %} {% flat_menu handle="footer" template="menus/custom_flat_menu_footer.html" %} + {% if settings.content_manager.CmsDsfrConfig.theme_modale_button %} +