From 6d21b86c33a8d94495947fb26564c52975825c95 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Tue, 14 Mar 2023 17:44:27 +0100 Subject: [PATCH 1/7] migrate homepage to cms --- lemarche/cms/blocks.py | 122 +++++++++++++ lemarche/cms/migrations/0003_homepage.py | 162 ++++++++++++++++++ lemarche/cms/models.py | 53 +++++- lemarche/templates/cms/home_page.html | 56 ++++++ .../cms/streams/section_our_partners.html | 74 ++++++++ .../cms/streams/section_our_ressources.html | 128 ++++++++++++++ .../cms/streams/section_our_siaes.html | 20 +++ .../section_studies_cases_tenders.html | 64 +++++++ .../streams/section_they_publish_tenders.html | 43 +++++ .../cms/streams/section_what_find_here.html | 48 ++++++ .../templates/cms/streams/stats_website.html | 9 + 11 files changed, 778 insertions(+), 1 deletion(-) create mode 100644 lemarche/cms/blocks.py create mode 100644 lemarche/cms/migrations/0003_homepage.py create mode 100644 lemarche/templates/cms/home_page.html create mode 100644 lemarche/templates/cms/streams/section_our_partners.html create mode 100644 lemarche/templates/cms/streams/section_our_ressources.html create mode 100644 lemarche/templates/cms/streams/section_our_siaes.html create mode 100644 lemarche/templates/cms/streams/section_studies_cases_tenders.html create mode 100644 lemarche/templates/cms/streams/section_they_publish_tenders.html create mode 100644 lemarche/templates/cms/streams/section_what_find_here.html create mode 100644 lemarche/templates/cms/streams/stats_website.html diff --git a/lemarche/cms/blocks.py b/lemarche/cms/blocks.py new file mode 100644 index 000000000..5975a4448 --- /dev/null +++ b/lemarche/cms/blocks.py @@ -0,0 +1,122 @@ +# common blocks +from django.utils.translation import gettext as _ +from wagtail.core import blocks + + +class ButtonBlock(blocks.StructBlock): + """An external or internal URL.""" + + title = blocks.CharBlock(required=True, max_length=60) + button_page = blocks.PageChooserBlock(required=False, help_text=_("If selected, this url will be used first")) + button_url = blocks.URLBlock( + required=False, help_text=_("If added, this url will be used secondarily to the button page") + ) + + # def get_context(self, request, *args, **kwargs): + # context = super().get_context(request, *args, **kwargs) + # context['latest_posts'] = BlogDetailPage.objects.live().public()[:3] + # return context + + class Meta: # noqa + template = "streams/button_block.html" + icon = "placeholder" + label = _("Single Button") + # value_class = LinkStructValue + + +class StatsWebsite(blocks.StructBlock): + """A stats of marche website section""" + + # def get_context(self, request, *args, **kwargs): + # context = super().get_context(request, *args, **kwargs) + # context['latest_posts'] = BlogDetailPage.objects.live().public()[:3] + # return context + + class Meta: # noqa + template = "cms/streams/stats_website.html" + icon = "pen" + label = _("Statistique du marche") + + +class SectionTheyPublishTenders(blocks.StructBlock): + + title = blocks.CharBlock(default="Ils ont publié un besoin sur le marché", required=True, max_length=120) + + class Meta: # noqa + template = "cms/streams/section_they_publish_tenders.html" + icon = "pen" + label = _("Ils ont publié un besoin sur le marché") + + +class SectionStudiesCasesTenders(blocks.StructBlock): + + title = blocks.CharBlock(default="100% des besoins ont reçu des réponses en 24h", required=True, max_length=120) + subtitle = blocks.CharBlock(default="Gagnez du temps en utilisant le marché.", required=True, max_length=120) + + class Meta: # noqa + template = "cms/streams/section_studies_cases_tenders.html" + icon = "pen" + label = _("Etude de cas") + + +class SectionOurSiaes(blocks.StructBlock): + """An external or internal URL.""" + + title = ( + blocks.CharBlock( + default="Les prestataires inclusifs, des partenaires d'excellence", required=True, max_length=60 + ), + ) + subtitle = blocks.RichTextBlock( + default=""" + Faire appel à nos 8500 prestataires inclusifs, c'est la garantie d'être accompagné + par des professionnels reconnus et certifiés dans leur domaine. + """, + required=True, + features=["bold", "italic"], + ) + # constats = blocks.StreamBlock( + # [ + # ( + # "constat", + # ConstatBlock(), + # ) + # ], + # min_num=1, + # max_num=3, + # ) + + class Meta: # noqa + template = "cms/streams/section_our_siaes.html" + icon = "pen" + label = _("Section nos structures") + + +class SectionOurRessources(blocks.StructBlock): + + title = blocks.CharBlock(default="Nos ressources", required=True, max_length=120) + + class Meta: # noqa + template = "cms/streams/section_our_ressources.html" + icon = "pen" + label = _("Nos ressources") + + +class SectionWhatFindHere(blocks.StructBlock): + + title = blocks.CharBlock(default="Sur le marché", required=True, max_length=120) + + class Meta: # noqa + template = "cms/streams/section_what_find_here.html" + icon = "pen" + label = _("Avantages marché") + + +class SectionOurPartners(blocks.StructBlock): + + title = blocks.CharBlock(default="Les partenaires du marché", required=True, max_length=120) + + class Meta: # noqa + template = "cms/streams/section_our_partners.html" + icon = "pen" + label = _("Nos partenaires") diff --git a/lemarche/cms/migrations/0003_homepage.py b/lemarche/cms/migrations/0003_homepage.py new file mode 100644 index 000000000..bab2421d3 --- /dev/null +++ b/lemarche/cms/migrations/0003_homepage.py @@ -0,0 +1,162 @@ +# Generated by Django 4.1.6 on 2023-03-14 15:39 + +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0083_workflowcontenttype"), + ("cms", "0002_articlepage_with_cta_tender"), + ] + + operations = [ + migrations.CreateModel( + name="HomePage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ( + "banner_title", + models.CharField( + default="Votre recherche de prestataires inclusifs est chronophage ?", max_length=120 + ), + ), + ( + "banner_subtitle", + models.CharField( + blank=True, default="Confiez votre sourcing au marché de l'inclusion !", max_length=120 + ), + ), + ( + "banner_id_call_to_action", + models.SlugField( + allow_unicode=True, + help_text="id du call to action (pour le suivi)", + max_length=255, + verbose_name="slug", + ), + ), + ("banner_call_to_action", models.CharField(max_length=255, verbose_name="Titre du call to action")), + ( + "content", + 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( + [ + ( + "subtitle", + wagtail.blocks.RichTextBlock(features=["bold", "italic"], required=True), + ) + ] + ), + ), + ( + "section_our_ressources", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Ils ont publié un besoin sur le marché", + 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 + ), + ) + ] + ), + ), + ( + "section_our_partners", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Ils ont publié un besoin sur le marché", + max_length=120, + required=True, + ), + ) + ] + ), + ), + ], + blank=True, + null=True, + use_json_field=True, + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page",), + ), + ] diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index 5d8eee406..d3feccdcd 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -5,9 +5,10 @@ from modelcluster.fields import ParentalManyToManyField from wagtail.admin.panels import FieldPanel, MultiFieldPanel from wagtail.contrib.routable_page.models import RoutablePageMixin, route -from wagtail.fields import RichTextField +from wagtail.fields import RichTextField, StreamField from wagtail.models import Page +from lemarche.cms import blocks from lemarche.cms.forms import ArticlePageForm from lemarche.cms.snippets import ArticleCategory @@ -140,3 +141,53 @@ def post_search(self, request, *args, **kwargs): parent_page_types = ["wagtailcore.Page"] subpage_types = ["cms.ArticlePage"] + + +class HomePage(Page): + max_count = 1 + banner_title = models.CharField( + default="Votre recherche de prestataires inclusifs est chronophage ?", max_length=120 + ) + banner_subtitle = models.CharField( + blank=True, max_length=120, default="Confiez votre sourcing au marché de l'inclusion !" + ) + # banner_image = models.ForeignKey( + # "wagtailimages.Image", + # null=True, + # blank=False, + # on_delete=models.SET_NULL, + # # related_name='' + # ) + banner_id_call_to_action = models.SlugField( + default="home-demande", + verbose_name="slug", + allow_unicode=True, + max_length=255, + help_text="id du call to action (pour le suivi)", + ) + banner_call_to_action = models.CharField( + default="Publier un besoin d'achat", max_length=255, verbose_name="Titre du call to action" + ) + + content = StreamField( + [ + ("website_stats", blocks.StatsWebsite()), + ("section_they_publish_tenders", blocks.SectionTheyPublishTenders()), + ("section_studies_cases_tenders", blocks.SectionStudiesCasesTenders()), + ("section_our_siaes", blocks.SectionOurSiaes()), + ("section_our_ressources", blocks.SectionOurRessources()), + ("section_what_find_here", blocks.SectionWhatFindHere()), + ("section_our_partners", blocks.SectionOurRessources()), + ], + null=True, + blank=True, + use_json_field=True, + ) + + content_panels = Page.content_panels + [ + FieldPanel("banner_title"), + FieldPanel("banner_subtitle"), + FieldPanel("banner_id_call_to_action"), + FieldPanel("banner_call_to_action"), + FieldPanel("content"), + ] diff --git a/lemarche/templates/cms/home_page.html b/lemarche/templates/cms/home_page.html new file mode 100644 index 000000000..ce3c8d59f --- /dev/null +++ b/lemarche/templates/cms/home_page.html @@ -0,0 +1,56 @@ +{% extends "layouts/base.html" %} +{% load static bootstrap4 %} + +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} + +{% block meta_description %} + +{% endblock %} +{% block body_class %}p-homepage{{ block.super }}{% endblock %} + +{% block title %}{{ page.title }} | {{ block.super }}{% endblock %} + +{% block content %} +
+
+
+
+

{{page.banner_title}}

+

{{page.banner_subtitle}}

+
    +
  • + + Obtenez des réponses en moins de 24 heures. +
  • +
  • + + Uniquement des prestataires conventionnés par l'Etat. +
  • +
  • + + Impact social garanti. +
  • +
+

+ + {{page.banner_call_to_action}} + + ou + + Rechercher un prestataire + +

+
+
+
+
+ +{% for block in page.content %} + {% include_block block %} +{% endfor %} +{% endblock %} + +{% block modals %} + {% include "auth/_login_or_signup_modal.html" %} +{% endblock %} diff --git a/lemarche/templates/cms/streams/section_our_partners.html b/lemarche/templates/cms/streams/section_our_partners.html new file mode 100644 index 000000000..755ef530f --- /dev/null +++ b/lemarche/templates/cms/streams/section_our_partners.html @@ -0,0 +1,74 @@ + +{% load static bootstrap4 %} + +
+
+
+
+

Les partenaires du marché

+
+
+
+
+ + Banque BNP Paribas | La banque d'un monde qui change + +
+
+ + Achetez des Timbres, Envoyez Courrier, Colis - La Poste + +
+
+ + Groupe pharmaceutique Servier + +
+
+ + Les entreprises s'engagent + +
+
+ + Conseil National des Achats + +
+
+ + Développer vos achats responsables auprès du STPA (ESAT & EA) + +
+
+ + Handeco - Le partenaire économique des acteurs solidaires + +
+
+ + ESS 2024 La plateforme solidaire + +
+
+ + Campus de l'inclusion : Dirigeants, passez à l'action ! + +
+
+ + Agence des Economies Solidaires + +
+
+ + Fédération des Entreprises d'Insertion + +
+
+ + Up France + +
+
+
+
\ No newline at end of file diff --git a/lemarche/templates/cms/streams/section_our_ressources.html b/lemarche/templates/cms/streams/section_our_ressources.html new file mode 100644 index 000000000..6699c2189 --- /dev/null +++ b/lemarche/templates/cms/streams/section_our_ressources.html @@ -0,0 +1,128 @@ +{% load static bootstrap4 wagtailcore_tags %} + +
+
+
+
+

Nos ressources

+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/lemarche/templates/cms/streams/section_our_siaes.html b/lemarche/templates/cms/streams/section_our_siaes.html new file mode 100644 index 000000000..23280599d --- /dev/null +++ b/lemarche/templates/cms/streams/section_our_siaes.html @@ -0,0 +1,20 @@ +{% load static %} + +
+
+
+
+ Logos de différents labels et certifications +
+
+

Les prestataires inclusifs, des partenaires d'excellence

+

+ Faire appel à nos 8500 prestataires inclusifs, c'est la garantie d'être accompagné par des professionnels reconnus et certifiés dans leur domaine. +

+ + Publier un besoin d'achat + +
+
+
+
diff --git a/lemarche/templates/cms/streams/section_studies_cases_tenders.html b/lemarche/templates/cms/streams/section_studies_cases_tenders.html new file mode 100644 index 000000000..e32d378b3 --- /dev/null +++ b/lemarche/templates/cms/streams/section_studies_cases_tenders.html @@ -0,0 +1,64 @@ +{% load static bootstrap4 wagtailcore_tags %} + +
+
+
+
+

100% des besoins ont reçu des réponses en 24h

+

Gagnez du temps en utilisant le marché.

+ + Publier un besoin d'achat + +
+
+ +
+
+ + +
+
+ +
+
+
+
diff --git a/lemarche/templates/cms/streams/section_they_publish_tenders.html b/lemarche/templates/cms/streams/section_they_publish_tenders.html new file mode 100644 index 000000000..784beec1c --- /dev/null +++ b/lemarche/templates/cms/streams/section_they_publish_tenders.html @@ -0,0 +1,43 @@ +{% load static bootstrap4 %} + +
+
+
+
+

Ils ont publié un besoin sur le marché

+
+
+
+
+ Bouygues energies et services +
+
+ Le Campus est un programme destiné aux dirigeant.e.s d'entreprise afin de développer leurs pratiques inclusives +
+
+ SNCF, groupe international de mobilité de personnes et de logistique de marchandises +
+
+ Korus, spécialiste de la conception, de l'aménagement et de la gestion d'espaces professionnels +
+
+ Siemens France +
+
+ Radio France +
+
+ Mairie d'Orsay +
+
+ Mairie de Saint-Germain-en-Laye +
+
+ Fédération des Entreprises d'Insertion +
+
+ 13 Habitat, 1er bailleur social public dans les Bouches-du-Rhône et en région Provence-Alpes-Côte d'Azur +
+
+
+
diff --git a/lemarche/templates/cms/streams/section_what_find_here.html b/lemarche/templates/cms/streams/section_what_find_here.html new file mode 100644 index 000000000..60904612f --- /dev/null +++ b/lemarche/templates/cms/streams/section_what_find_here.html @@ -0,0 +1,48 @@ + +{% load static bootstrap4 %} +{% load theme_inclusion %} + +
+
+
+
+

Sur le marché

+
+
+
+
+
+
+ +
+
+

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.

+
+ +
+
+
+
+
\ No newline at end of file diff --git a/lemarche/templates/cms/streams/stats_website.html b/lemarche/templates/cms/streams/stats_website.html new file mode 100644 index 000000000..c50178aa7 --- /dev/null +++ b/lemarche/templates/cms/streams/stats_website.html @@ -0,0 +1,9 @@ +
+
+
+
+

Le marché c'est {{ user_buyer_count }} acheteurs inscrits, {{ siae_count }} prestataires référencés, {{ tender_count }} besoins publiés.

+
+
+
+
\ No newline at end of file From b019307ffb77506d0b01a3a4caa62d83644f771b Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 15 Mar 2023 16:02:31 +0100 Subject: [PATCH 2/7] improve wording of variables --- lemarche/cms/blocks.py | 67 ++++++------------- .../{0003_homepage.py => 0004_homepage.py} | 28 +++++--- lemarche/cms/models.py | 20 +++--- lemarche/templates/cms/home_page.html | 4 +- 4 files changed, 50 insertions(+), 69 deletions(-) rename lemarche/cms/migrations/{0003_homepage.py => 0004_homepage.py} (86%) diff --git a/lemarche/cms/blocks.py b/lemarche/cms/blocks.py index 5975a4448..1457bc8a2 100644 --- a/lemarche/cms/blocks.py +++ b/lemarche/cms/blocks.py @@ -1,65 +1,40 @@ # common blocks -from django.utils.translation import gettext as _ -from wagtail.core import blocks - - -class ButtonBlock(blocks.StructBlock): - """An external or internal URL.""" - - title = blocks.CharBlock(required=True, max_length=60) - button_page = blocks.PageChooserBlock(required=False, help_text=_("If selected, this url will be used first")) - button_url = blocks.URLBlock( - required=False, help_text=_("If added, this url will be used secondarily to the button page") - ) - - # def get_context(self, request, *args, **kwargs): - # context = super().get_context(request, *args, **kwargs) - # context['latest_posts'] = BlogDetailPage.objects.live().public()[:3] - # return context - - class Meta: # noqa - template = "streams/button_block.html" - icon = "placeholder" - label = _("Single Button") - # value_class = LinkStructValue +from wagtail import blocks class StatsWebsite(blocks.StructBlock): """A stats of marche website section""" # def get_context(self, request, *args, **kwargs): - # context = super().get_context(request, *args, **kwargs) - # context['latest_posts'] = BlogDetailPage.objects.live().public()[:3] - # return context - class Meta: # noqa + class Meta: template = "cms/streams/stats_website.html" icon = "pen" - label = _("Statistique du marche") + label = "Statistique du marche" -class SectionTheyPublishTenders(blocks.StructBlock): +class TendersTestimonialsSection(blocks.StructBlock): title = blocks.CharBlock(default="Ils ont publié un besoin sur le marché", required=True, max_length=120) - class Meta: # noqa + class Meta: template = "cms/streams/section_they_publish_tenders.html" icon = "pen" - label = _("Ils ont publié un besoin sur le marché") + label = "Ils ont publié un besoin sur le marché" -class SectionStudiesCasesTenders(blocks.StructBlock): +class TendersStudiesCasesSection(blocks.StructBlock): title = blocks.CharBlock(default="100% des besoins ont reçu des réponses en 24h", required=True, max_length=120) subtitle = blocks.CharBlock(default="Gagnez du temps en utilisant le marché.", required=True, max_length=120) - class Meta: # noqa + class Meta: template = "cms/streams/section_studies_cases_tenders.html" icon = "pen" - label = _("Etude de cas") + label = "Etude de cas" -class SectionOurSiaes(blocks.StructBlock): +class OurSiaesSection(blocks.StructBlock): """An external or internal URL.""" title = ( @@ -86,37 +61,37 @@ class SectionOurSiaes(blocks.StructBlock): # max_num=3, # ) - class Meta: # noqa + class Meta: template = "cms/streams/section_our_siaes.html" icon = "pen" - label = _("Section nos structures") + label = "Section nos structures" -class SectionOurRessources(blocks.StructBlock): +class OurRessourcesSection(blocks.StructBlock): title = blocks.CharBlock(default="Nos ressources", required=True, max_length=120) - class Meta: # noqa + class Meta: template = "cms/streams/section_our_ressources.html" icon = "pen" - label = _("Nos ressources") + label = "Nos ressources" -class SectionWhatFindHere(blocks.StructBlock): +class WhatFindHereSection(blocks.StructBlock): title = blocks.CharBlock(default="Sur le marché", required=True, max_length=120) - class Meta: # noqa + class Meta: template = "cms/streams/section_what_find_here.html" icon = "pen" - label = _("Avantages marché") + label = "Avantages marché" -class SectionOurPartners(blocks.StructBlock): +class OurPartnersSection(blocks.StructBlock): title = blocks.CharBlock(default="Les partenaires du marché", required=True, max_length=120) - class Meta: # noqa + class Meta: template = "cms/streams/section_our_partners.html" icon = "pen" - label = _("Nos partenaires") + label = "Nos partenaires" diff --git a/lemarche/cms/migrations/0003_homepage.py b/lemarche/cms/migrations/0004_homepage.py similarity index 86% rename from lemarche/cms/migrations/0003_homepage.py rename to lemarche/cms/migrations/0004_homepage.py index bab2421d3..2a525b3f4 100644 --- a/lemarche/cms/migrations/0003_homepage.py +++ b/lemarche/cms/migrations/0004_homepage.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.6 on 2023-03-14 15:39 +# Generated by Django 4.1.6 on 2023-03-15 14:58 import django.db.models.deletion import wagtail.blocks @@ -10,7 +10,7 @@ class Migration(migrations.Migration): dependencies = [ ("wagtailcore", "0083_workflowcontenttype"), - ("cms", "0002_articlepage_with_cta_tender"), + ("cms", "0003_advert"), ] operations = [ @@ -41,15 +41,21 @@ class Migration(migrations.Migration): ), ), ( - "banner_id_call_to_action", + "banner_cta_id", models.SlugField( allow_unicode=True, + default="home-demande", help_text="id du call to action (pour le suivi)", max_length=255, verbose_name="slug", ), ), - ("banner_call_to_action", models.CharField(max_length=255, verbose_name="Titre du call to action")), + ( + "banner_cta_text", + models.CharField( + default="Publier un besoin d'achat", max_length=255, verbose_name="Titre du call to action" + ), + ), ( "content", wagtail.fields.StreamField( @@ -99,7 +105,11 @@ class Migration(migrations.Migration): [ ( "subtitle", - wagtail.blocks.RichTextBlock(features=["bold", "italic"], required=True), + 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, + ), ) ] ), @@ -111,9 +121,7 @@ class Migration(migrations.Migration): ( "title", wagtail.blocks.CharBlock( - default="Ils ont publié un besoin sur le marché", - max_length=120, - required=True, + default="Nos ressources", max_length=120, required=True ), ) ] @@ -139,9 +147,7 @@ class Migration(migrations.Migration): ( "title", wagtail.blocks.CharBlock( - default="Ils ont publié un besoin sur le marché", - max_length=120, - required=True, + default="Nos ressources", max_length=120, required=True ), ) ] diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index d3feccdcd..0d37f2a24 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -158,26 +158,26 @@ class HomePage(Page): # on_delete=models.SET_NULL, # # related_name='' # ) - banner_id_call_to_action = models.SlugField( + banner_cta_id = models.SlugField( default="home-demande", verbose_name="slug", allow_unicode=True, max_length=255, help_text="id du call to action (pour le suivi)", ) - banner_call_to_action = models.CharField( + banner_cta_text = models.CharField( default="Publier un besoin d'achat", max_length=255, verbose_name="Titre du call to action" ) content = StreamField( [ ("website_stats", blocks.StatsWebsite()), - ("section_they_publish_tenders", blocks.SectionTheyPublishTenders()), - ("section_studies_cases_tenders", blocks.SectionStudiesCasesTenders()), - ("section_our_siaes", blocks.SectionOurSiaes()), - ("section_our_ressources", blocks.SectionOurRessources()), - ("section_what_find_here", blocks.SectionWhatFindHere()), - ("section_our_partners", blocks.SectionOurRessources()), + ("section_they_publish_tenders", blocks.TendersTestimonialsSection()), + ("section_studies_cases_tenders", blocks.TendersStudiesCasesSection()), + ("section_our_siaes", blocks.OurSiaesSection()), + ("section_our_ressources", blocks.OurRessourcesSection()), + ("section_what_find_here", blocks.WhatFindHereSection()), + ("section_our_partners", blocks.OurRessourcesSection()), ], null=True, blank=True, @@ -187,7 +187,7 @@ class HomePage(Page): content_panels = Page.content_panels + [ FieldPanel("banner_title"), FieldPanel("banner_subtitle"), - FieldPanel("banner_id_call_to_action"), - FieldPanel("banner_call_to_action"), + FieldPanel("banner_cta_id"), + FieldPanel("banner_cta_text"), FieldPanel("content"), ] diff --git a/lemarche/templates/cms/home_page.html b/lemarche/templates/cms/home_page.html index ce3c8d59f..b2fdea29f 100644 --- a/lemarche/templates/cms/home_page.html +++ b/lemarche/templates/cms/home_page.html @@ -33,8 +33,8 @@

{{page.banner_subtitle}}

- - {{page.banner_call_to_action}} + + {{page.banner_cta_text}} ou From be2bdbeafb1e975af407c2bf8e1f616640924162 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 15 Mar 2023 17:22:34 +0100 Subject: [PATCH 3/7] manage migration of homepage --- lemarche/cms/migrations/0004_homepage.py | 13 +++++++++++++ scripts/create_wagtail_homepage.py | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/create_wagtail_homepage.py diff --git a/lemarche/cms/migrations/0004_homepage.py b/lemarche/cms/migrations/0004_homepage.py index 2a525b3f4..81e377a4e 100644 --- a/lemarche/cms/migrations/0004_homepage.py +++ b/lemarche/cms/migrations/0004_homepage.py @@ -6,6 +6,18 @@ from django.db import migrations, models +def remove_homepage(apps, schema_editor): + Homepage = apps.get_model("cms", "homepage") + # need to delete first the homepage, go to scripts/create_wagtail_homepage.py + # comment above line (after script delete) to downgrade the migration + Homepage.objects.first().delete() + + +def create_homepage(apps, schema_editor): + # use script scripts/create_wagtail_homepage.py + pass + + class Migration(migrations.Migration): dependencies = [ @@ -165,4 +177,5 @@ class Migration(migrations.Migration): }, bases=("wagtailcore.page",), ), + migrations.RunPython(code=create_homepage, reverse_code=remove_homepage), ] diff --git a/scripts/create_wagtail_homepage.py b/scripts/create_wagtail_homepage.py new file mode 100644 index 000000000..1fe8338f7 --- /dev/null +++ b/scripts/create_wagtail_homepage.py @@ -0,0 +1,16 @@ +# script to use inside shell of django +from wagtail.models import Page + +from lemarche.cms.models import HomePage + + +def create_homepage(): + root = Page.get_first_root_node() + homepage = HomePage(title="Page d'accueil", slug="accueil") + root.add_child(instance=homepage) + + +def delete_homepage(): + # we can only have one homepage + hp = HomePage.objects.first() + hp.delete() From 64d91532f94bbdd9b83e3909bfb4618eb9066680 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 15 Mar 2023 17:48:18 +0100 Subject: [PATCH 4/7] update model --- lemarche/cms/migrations/0004_homepage.py | 6 +++++- lemarche/cms/models.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lemarche/cms/migrations/0004_homepage.py b/lemarche/cms/migrations/0004_homepage.py index 81e377a4e..fd0e737f9 100644 --- a/lemarche/cms/migrations/0004_homepage.py +++ b/lemarche/cms/migrations/0004_homepage.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.6 on 2023-03-15 14:58 +# Generated by Django 4.1.6 on 2023-03-15 16:32 import django.db.models.deletion import wagtail.blocks @@ -52,6 +52,10 @@ class Migration(migrations.Migration): blank=True, default="Confiez votre sourcing au marché de l'inclusion !", max_length=120 ), ), + ( + "banner_arguments_list", + wagtail.fields.StreamField([("item", wagtail.blocks.CharBlock())], use_json_field=True), + ), ( "banner_cta_id", models.SlugField( diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index 0d37f2a24..b0ed5f81c 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -3,6 +3,7 @@ from django.db import models from django.db.models import Q from modelcluster.fields import ParentalManyToManyField +from wagtail import blocks as wagtail_blocks from wagtail.admin.panels import FieldPanel, MultiFieldPanel from wagtail.contrib.routable_page.models import RoutablePageMixin, route from wagtail.fields import RichTextField, StreamField @@ -151,6 +152,14 @@ class HomePage(Page): banner_subtitle = models.CharField( blank=True, max_length=120, default="Confiez votre sourcing au marché de l'inclusion !" ) + banner_arguments_list = StreamField( + [ + ("item", wagtail_blocks.CharBlock()), + ], + min_num=3, + max_num=3, + use_json_field=True, + ) # banner_image = models.ForeignKey( # "wagtailimages.Image", # null=True, @@ -177,7 +186,7 @@ class HomePage(Page): ("section_our_siaes", blocks.OurSiaesSection()), ("section_our_ressources", blocks.OurRessourcesSection()), ("section_what_find_here", blocks.WhatFindHereSection()), - ("section_our_partners", blocks.OurRessourcesSection()), + ("section_our_partners", blocks.OurPartnersSection()), ], null=True, blank=True, @@ -189,5 +198,6 @@ class HomePage(Page): FieldPanel("banner_subtitle"), FieldPanel("banner_cta_id"), FieldPanel("banner_cta_text"), + FieldPanel("banner_arguments_list"), FieldPanel("content"), ] From e5082b5cf1b5392c2491ae10713c9aa719ffe895 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 15 Mar 2023 17:48:35 +0100 Subject: [PATCH 5/7] start clean html views --- lemarche/templates/cms/home_page.html | 12 +++--------- .../templates/cms/streams/section_our_siaes.html | 6 ++---- .../cms/streams/section_studies_cases_tenders.html | 4 ++-- .../cms/streams/section_they_publish_tenders.html | 2 +- .../cms/streams/section_what_find_here.html | 4 ++-- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/lemarche/templates/cms/home_page.html b/lemarche/templates/cms/home_page.html index b2fdea29f..c2da3d69e 100644 --- a/lemarche/templates/cms/home_page.html +++ b/lemarche/templates/cms/home_page.html @@ -19,18 +19,12 @@

{{page.banner_title}}

{{page.banner_subtitle}}

    + {% for item in page.banner_arguments_list %}
  • - Obtenez des réponses en moins de 24 heures. -
  • -
  • - - Uniquement des prestataires conventionnés par l'Etat. -
  • -
  • - - Impact social garanti. + {{item}}
  • + {% endfor %}

diff --git a/lemarche/templates/cms/streams/section_our_siaes.html b/lemarche/templates/cms/streams/section_our_siaes.html index 23280599d..043f91f62 100644 --- a/lemarche/templates/cms/streams/section_our_siaes.html +++ b/lemarche/templates/cms/streams/section_our_siaes.html @@ -7,10 +7,8 @@ Logos de différents labels et certifications

-

Les prestataires inclusifs, des partenaires d'excellence

-

- Faire appel à nos 8500 prestataires inclusifs, c'est la garantie d'être accompagné par des professionnels reconnus et certifiés dans leur domaine. -

+

{{self.title}}

+ {{self.subtitle}}
Publier un besoin d'achat diff --git a/lemarche/templates/cms/streams/section_studies_cases_tenders.html b/lemarche/templates/cms/streams/section_studies_cases_tenders.html index e32d378b3..beac0d65b 100644 --- a/lemarche/templates/cms/streams/section_studies_cases_tenders.html +++ b/lemarche/templates/cms/streams/section_studies_cases_tenders.html @@ -4,8 +4,8 @@
-

100% des besoins ont reçu des réponses en 24h

-

Gagnez du temps en utilisant le marché.

+

{{self.title}}

+

{{self.subtitle}}

Publier un besoin d'achat diff --git a/lemarche/templates/cms/streams/section_they_publish_tenders.html b/lemarche/templates/cms/streams/section_they_publish_tenders.html index 784beec1c..9e874bc15 100644 --- a/lemarche/templates/cms/streams/section_they_publish_tenders.html +++ b/lemarche/templates/cms/streams/section_they_publish_tenders.html @@ -4,7 +4,7 @@
-

Ils ont publié un besoin sur le marché

+

{{self.title}}

diff --git a/lemarche/templates/cms/streams/section_what_find_here.html b/lemarche/templates/cms/streams/section_what_find_here.html index 60904612f..83e9a991b 100644 --- a/lemarche/templates/cms/streams/section_what_find_here.html +++ b/lemarche/templates/cms/streams/section_what_find_here.html @@ -6,7 +6,7 @@
-

Sur le marché

+

{{self.title}}

@@ -16,7 +16,7 @@

Sur le marché

-

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

+

{{self.subtitle}}

From 73799be628061ec00015ab9e4a29c7c15bf15e1e Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Tue, 28 Mar 2023 14:00:06 +0200 Subject: [PATCH 6/7] alter model of homepage and make new migrations --- .../migrations/0005_alter_homepage_content.py | 112 ++++++++++++++++++ lemarche/cms/models.py | 14 ++- lemarche/templates/cms/home_page.html | 6 +- 3 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 lemarche/cms/migrations/0005_alter_homepage_content.py diff --git a/lemarche/cms/migrations/0005_alter_homepage_content.py b/lemarche/cms/migrations/0005_alter_homepage_content.py new file mode 100644 index 000000000..50de2639b --- /dev/null +++ b/lemarche/cms/migrations/0005_alter_homepage_content.py @@ -0,0 +1,112 @@ +# Generated by Django 4.1.6 on 2023-03-28 11:51 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("cms", "0004_homepage"), + ] + + 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( + [ + ( + "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), + ) + ] + ), + ), + ( + "section_our_partners", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + default="Les partenaires du marché", max_length=120, required=True + ), + ) + ] + ), + ), + ], + null=True, + use_json_field=True, + ), + ), + ] diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index b0ed5f81c..f352ae077 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -140,7 +140,7 @@ def post_search(self, request, *args, **kwargs): request, ) - parent_page_types = ["wagtailcore.Page"] + # parent_page_types = ["cms.HomePage"] subpage_types = ["cms.ArticlePage"] @@ -189,7 +189,15 @@ class HomePage(Page): ("section_our_partners", blocks.OurPartnersSection()), ], null=True, - blank=True, + block_counts={ + "website_stats": {"min_num": 1, "max_num": 1}, + "section_they_publish_tenders": {"min_num": 1, "max_num": 1}, + "section_studies_cases_tenders": {"min_num": 1, "max_num": 1}, + "section_our_siaes": {"min_num": 1, "max_num": 1}, + "section_our_ressource": {"min_num": 1, "max_num": 1}, + "section_what_find_her": {"min_num": 1, "max_num": 1}, + "section_our_partners": {"min_num": 1, "max_num": 1}, + }, use_json_field=True, ) @@ -201,3 +209,5 @@ class HomePage(Page): FieldPanel("banner_arguments_list"), FieldPanel("content"), ] + + parent_page_types = ["wagtailcore.Page"] diff --git a/lemarche/templates/cms/home_page.html b/lemarche/templates/cms/home_page.html index c2da3d69e..1af1d9db7 100644 --- a/lemarche/templates/cms/home_page.html +++ b/lemarche/templates/cms/home_page.html @@ -12,12 +12,14 @@ {% block title %}{{ page.title }} | {{ block.super }}{% endblock %} {% block content %} -
+

{{page.banner_title}}

-

{{page.banner_subtitle}}

+ {% if page.banner_subtitle %} +

{{page.banner_subtitle}}

+ {% endif %}
    {% for item in page.banner_arguments_list %}
  • From 249f6720e208b95fd4c21b333dba0dc9fcbfcdc2 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Tue, 28 Mar 2023 17:33:50 +0200 Subject: [PATCH 7/7] fix error --- lemarche/cms/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index f352ae077..600862138 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -194,8 +194,8 @@ class HomePage(Page): "section_they_publish_tenders": {"min_num": 1, "max_num": 1}, "section_studies_cases_tenders": {"min_num": 1, "max_num": 1}, "section_our_siaes": {"min_num": 1, "max_num": 1}, - "section_our_ressource": {"min_num": 1, "max_num": 1}, - "section_what_find_her": {"min_num": 1, "max_num": 1}, + "section_our_ressources": {"min_num": 1, "max_num": 1}, + "section_what_find_here": {"min_num": 1, "max_num": 1}, "section_our_partners": {"min_num": 1, "max_num": 1}, }, use_json_field=True,