From 2cd8ed2b50ec41b53e9b78b773e0bc743ee8e095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Reuiller?= Date: Thu, 21 Mar 2024 18:24:21 +0100 Subject: [PATCH] dynamic WhatFindHere card --- lemarche/cms/blocks.py | 18 ++ .../migrations/0011_alter_homepage_content.py | 230 ++++++++++++++++++ .../cms/streams/section_what_find_here.html | 46 ++-- 3 files changed, 262 insertions(+), 32 deletions(-) create mode 100644 lemarche/cms/migrations/0011_alter_homepage_content.py diff --git a/lemarche/cms/blocks.py b/lemarche/cms/blocks.py index 754231372..4f4ed5382 100644 --- a/lemarche/cms/blocks.py +++ b/lemarche/cms/blocks.py @@ -92,9 +92,27 @@ class Meta: label = "Nos ressources" +class WhatFindHereCardBlock(blocks.StructBlock): + ico = blocks.CharBlock( + label="Icone bicro", help_text="Ico du thème (Ex: ico-bicro-marche-recyclage)", required=True, max_length=100 + ) + text = blocks.CharBlock(required=True, max_length=200) + + class WhatFindHereSection(blocks.StructBlock): title = blocks.CharBlock(default="Sur le marché", required=True, max_length=120) + cards = blocks.StreamBlock( + [ + ( + "card", + WhatFindHereCardBlock(), + ) + ], + min_num=3, + max_num=3, + ) + class Meta: template = "cms/streams/section_what_find_here.html" icon = "pen" diff --git a/lemarche/cms/migrations/0011_alter_homepage_content.py b/lemarche/cms/migrations/0011_alter_homepage_content.py new file mode 100644 index 000000000..164f64a52 --- /dev/null +++ b/lemarche/cms/migrations/0011_alter_homepage_content.py @@ -0,0 +1,230 @@ +# Generated by Django 4.2.2 on 2024-03-21 17:08 + +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("cms", "0010_remove_homepage_banner_cta_id_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="homepage", + name="content", + field=wagtail.fields.StreamField( + [ + ("website_stats", wagtail.blocks.StructBlock([])), + ( + "section_they_publish_tenders", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Ils ont publié un besoin sur le marché", max_length=120, required=True + ), + ) + ] + ), + ), + ( + "section_studies_cases_tenders", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="100% des besoins ont reçu des réponses en 24h", + max_length=120, + required=True, + ), + ), + ( + "subtitle", + wagtail.blocks.CharBlock( + default="Gagnez du temps en utilisant le marché.", + max_length=120, + required=True, + ), + ), + ] + ), + ), + ( + "section_our_siaes", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Les prestataires inclusifs, des partenaires d'excellence", + max_length=60, + required=True, + ), + ), + ( + "subtitle", + wagtail.blocks.RichTextBlock( + default="\n Faire appel à nos 8500 prestataires inclusifs, c'est la garantie d'être accompagné\n par des professionnels reconnus et certifiés dans leur domaine.\n ", # noqa + features=["bold", "italic"], + required=True, + ), + ), + ] + ), + ), + ( + "section_our_ressources", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock(default="Nos ressources", max_length=120, required=True), + ) + ] + ), + ), + ( + "section_what_find_here", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock(default="Sur le marché", max_length=120, required=True), + ), + ( + "cards", + wagtail.blocks.StreamBlock( + [ + ( + "card", + wagtail.blocks.StructBlock( + [ + ( + "ico", + wagtail.blocks.CharBlock( + help_text="Ico du thème (Ex: ico-bicro-marche-recyclage)", # noqa + label="Icone bicro", + max_length=100, + required=True, + ), + ), + ( + "text", + wagtail.blocks.CharBlock(max_length=200, required=True), + ), + ] + ), + ) + ], + max_num=3, + min_num=3, + ), + ), + ] + ), + ), + ( + "section_our_partners", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Les partenaires du marché", max_length=120, required=True + ), + ), + ( + "images_with_link", + wagtail.blocks.StreamBlock( + [ + ( + "images", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(required=True), + ), + ("external_link", wagtail.blocks.URLBlock(required=True)), + ] + ), + ) + ], + max_num=8, + min_num=8, + ), + ), + ] + ), + ), + ( + "section_our_features", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Une solution complète pour vos achats socialement responsables", + max_length=120, + required=True, + ), + ), + ( + "constats", + wagtail.blocks.StreamBlock( + [ + ( + "feature", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock(max_length=60, required=True), + ), + ( + "subtitle", + wagtail.blocks.RichTextBlock( + features=["bold", "italic"], required=True + ), + ), + ( + "image", + wagtail.images.blocks.ImageChooserBlock(required=True), + ), + ("url", wagtail.blocks.URLBlock(required=True)), + ] + ), + ) + ], + min_num=1, + ), + ), + ] + ), + ), + ( + "section_why_call_siaes", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Pourquoi faire appel à un prestataire inclusif ?", + max_length=120, + required=True, + ), + ) + ] + ), + ), + ], + null=True, + use_json_field=True, + ), + ), + ] diff --git a/lemarche/templates/cms/streams/section_what_find_here.html b/lemarche/templates/cms/streams/section_what_find_here.html index 0e12b9c1f..f328d1a0e 100644 --- a/lemarche/templates/cms/streams/section_what_find_here.html +++ b/lemarche/templates/cms/streams/section_what_find_here.html @@ -10,39 +10,21 @@

{{self.title}}

-
-
-
- + {% for card in self.cards %} +
+
+
+ {% with card.value.ico|add:".svg" as ico %} + + {% endwith %} +
+
+

{{ card.value.text }}

+
+
-
-

Participez à la dynamique économique et sociale de votre territoire avec des partenaires de proximité.

-
- -
-
-
-
-
- -
-
-

Mesurer vos achats inclusifs, renforcez votre politique d’achats responsables et valorisez votre image d’entreprise.

-
-
-
-
-
-
- -
-
-

Trouvez des prestataires et palliez efficacement vos besoins de main-d'œuvre, métiers en tension, et vos besoins de services.

-
- -
-
+ {% endfor %}
- \ No newline at end of file +