feat: add contact form
This commit is contained in:
parent
6fd74833a3
commit
b6554fbf83
5 changed files with 129 additions and 4 deletions
|
@ -1,9 +1,12 @@
|
|||
from django.db import models
|
||||
from modelcluster.models import ClusterableModel
|
||||
from modelcluster.fields import ParentalKey
|
||||
|
||||
from wagtail.admin.panels import (
|
||||
FieldPanel,
|
||||
MultiFieldPanel,
|
||||
PublishingPanel
|
||||
PublishingPanel,
|
||||
FieldRowPanel,
|
||||
InlinePanel
|
||||
)
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import (
|
||||
|
@ -12,13 +15,18 @@ from wagtail.models import (
|
|||
RevisionMixin,
|
||||
TranslatableMixin,
|
||||
)
|
||||
|
||||
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
|
||||
|
||||
from wagtail.snippets.models import register_snippet
|
||||
from wagtail.contrib.forms.panels import FormSubmissionsPanel
|
||||
|
||||
from wagtail.contrib.settings.models import (
|
||||
BaseGenericSetting,
|
||||
register_setting,
|
||||
)
|
||||
|
||||
|
||||
@register_setting
|
||||
class NavigationSettings(BaseGenericSetting):
|
||||
linkedin_url = models.URLField(verbose_name="LinkedIn URL", blank=True)
|
||||
|
@ -36,6 +44,7 @@ class NavigationSettings(BaseGenericSetting):
|
|||
)
|
||||
]
|
||||
|
||||
|
||||
@register_snippet
|
||||
class FooterText(
|
||||
DraftStateMixin,
|
||||
|
@ -44,7 +53,6 @@ class FooterText(
|
|||
TranslatableMixin,
|
||||
models.Model,
|
||||
):
|
||||
|
||||
body = RichTextField()
|
||||
|
||||
panels = [
|
||||
|
@ -62,4 +70,27 @@ class FooterText(
|
|||
return {"footer_text": self.body}
|
||||
|
||||
class Meta(TranslatableMixin.Meta):
|
||||
verbose_name_plural = "Footer Text"
|
||||
verbose_name_plural = "Footer Text"
|
||||
|
||||
|
||||
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="Form fields"),
|
||||
FieldPanel('thank_you_text'),
|
||||
MultiFieldPanel([
|
||||
FieldRowPanel([
|
||||
FieldPanel('from_address'),
|
||||
FieldPanel('to_address'),
|
||||
]),
|
||||
FieldPanel('subject'),
|
||||
], "Email"),
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue