Archived
1
Fork 0
This repository has been archived on 2024-10-15. You can view files and clone it, but cannot push or open issues or pull requests.
lps-wagtail/lps/base/models.py

86 lines
2.5 KiB
Python
Raw Normal View History

2024-06-12 17:54:11 +02:00
from django.db import models
from modelcluster.fields import ParentalKey
2024-06-13 09:02:53 +02:00
from wagtail import blocks
2024-06-12 17:54:11 +02:00
from wagtail.admin.panels import FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
from wagtail.contrib.forms.panels import FormSubmissionsPanel
from wagtail.contrib.settings.models import BaseGenericSetting, register_setting
2024-06-13 09:02:53 +02:00
from wagtail.fields import RichTextField, StreamField
2024-06-12 17:54:11 +02:00
@register_setting
class NavigationSettings(BaseGenericSetting):
address = models.CharField(max_length=256, verbose_name="Adresse", blank=True)
phone = models.CharField(
max_length=32, verbose_name="Numéro de téléphone", blank=True
)
email = models.EmailField(verbose_name="Adresse de courriel", blank=True)
2024-06-13 09:02:53 +02:00
links = StreamField(
[
(
"link",
blocks.StructBlock(
[
("title", blocks.CharBlock()),
("url", blocks.URLBlock()),
]
),
)
],
blank=True,
)
2024-06-12 17:54:11 +02:00
panels = [
MultiFieldPanel(
[
FieldPanel("address"),
FieldPanel("phone"),
FieldPanel("email"),
2024-06-13 09:02:53 +02:00
FieldPanel("links"),
2024-06-12 17:54:11 +02:00
],
"Informations de contact",
)
]
2024-06-12 19:13:27 +02:00
2024-06-12 19:02:56 +02:00
@register_setting
class SiteSettings(BaseGenericSetting):
icon = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
help_text="Icône du site",
)
2024-06-12 19:13:27 +02:00
panels = [MultiFieldPanel([FieldPanel("icon")], "Informations du site")]
2024-06-12 19:02:56 +02:00
2024-06-12 17:54:11 +02:00
class FormField(AbstractFormField):
page = ParentalKey("FormPage", on_delete=models.CASCADE, related_name="form_fields")
class FormPage(AbstractEmailForm):
intro = RichTextField(blank=True)
thank_you_text = RichTextField(blank=True)
content_panels = AbstractEmailForm.content_panels + [
FormSubmissionsPanel(),
FieldPanel("intro"),
InlinePanel("form_fields", label="Champs de formulaire"),
FieldPanel("thank_you_text"),
MultiFieldPanel(
[
FieldRowPanel(
[
FieldPanel("from_address"),
FieldPanel("to_address"),
]
),
FieldPanel("subject"),
],
"Email",
),
]