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
2024-06-12 17:54:11 +02:00

55 lines
1.8 KiB
Python

from django.db import models
from modelcluster.fields import ParentalKey
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
from wagtail.fields import RichTextField
@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)
panels = [
MultiFieldPanel(
[
FieldPanel("address"),
FieldPanel("phone"),
FieldPanel("email"),
],
"Informations de contact",
)
]
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",
),
]