69 lines
2.1 KiB
Python
69 lines
2.1 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",
|
|
)
|
|
]
|
|
|
|
|
|
@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",
|
|
)
|
|
|
|
panels = [MultiFieldPanel([FieldPanel("icon")], "Informations du site")]
|
|
|
|
|
|
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",
|
|
),
|
|
]
|