Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrer la homepage sur wagtail #696

Merged
merged 7 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions lemarche/cms/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# common blocks
from wagtail import blocks


class StatsWebsite(blocks.StructBlock):
"""A stats of marche website section"""

# def get_context(self, request, *args, **kwargs):

class Meta:
template = "cms/streams/stats_website.html"
icon = "pen"
label = "Statistique du marche"


class TendersTestimonialsSection(blocks.StructBlock):

title = blocks.CharBlock(default="Ils ont publié un besoin sur le marché", required=True, max_length=120)

class Meta:
template = "cms/streams/section_they_publish_tenders.html"
icon = "pen"
label = "Ils ont publié un besoin sur le marché"


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:
template = "cms/streams/section_studies_cases_tenders.html"
icon = "pen"
label = "Etude de cas"


class OurSiaesSection(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:
template = "cms/streams/section_our_siaes.html"
icon = "pen"
label = "Section nos structures"


class OurRessourcesSection(blocks.StructBlock):

title = blocks.CharBlock(default="Nos ressources", required=True, max_length=120)

class Meta:
template = "cms/streams/section_our_ressources.html"
icon = "pen"
label = "Nos ressources"


class WhatFindHereSection(blocks.StructBlock):

title = blocks.CharBlock(default="Sur le marché", required=True, max_length=120)

class Meta:
template = "cms/streams/section_what_find_here.html"
icon = "pen"
label = "Avantages marché"


class OurPartnersSection(blocks.StructBlock):

title = blocks.CharBlock(default="Les partenaires du marché", required=True, max_length=120)

class Meta:
template = "cms/streams/section_our_partners.html"
icon = "pen"
label = "Nos partenaires"
185 changes: 185 additions & 0 deletions lemarche/cms/migrations/0004_homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Generated by Django 4.1.6 on 2023-03-15 16:32

import django.db.models.deletion
import wagtail.blocks
import wagtail.fields
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 = [
("wagtailcore", "0083_workflowcontenttype"),
("cms", "0003_advert"),
]

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_arguments_list",
wagtail.fields.StreamField([("item", wagtail.blocks.CharBlock())], use_json_field=True),
),
(
"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_cta_text",
models.CharField(
default="Publier un besoin d'achat", 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(
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="Nos ressources", max_length=120, required=True
),
)
]
),
),
],
blank=True,
null=True,
use_json_field=True,
),
),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
migrations.RunPython(code=create_homepage, reverse_code=remove_homepage),
]
112 changes: 112 additions & 0 deletions lemarche/cms/migrations/0005_alter_homepage_content.py
Original file line number Diff line number Diff line change
@@ -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,
),
),
]
Loading