public-health-ch/publichealth/home/models/forms.py

41 lines
1.2 KiB
Python
Raw Normal View History

2017-04-08 15:47:10 +02:00
# -*- coding: utf-8 -*-
from modelcluster.fields import ParentalKey
from django.db.models import CharField
2017-05-03 23:13:30 +02:00
2019-05-13 17:11:16 +02:00
from wagtail.core.fields import RichTextField
from wagtail.contrib.forms.models import (
2017-04-08 15:47:10 +02:00
AbstractEmailForm, AbstractFormField
)
2019-05-13 17:11:16 +02:00
from wagtail.admin.edit_handlers import (
2017-05-03 23:13:30 +02:00
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
2017-04-08 15:47:10 +02:00
from ..util import TranslatedField
class ContactFormField(AbstractFormField):
page = ParentalKey('ContactForm', related_name='form_fields')
2017-05-03 23:35:23 +02:00
class ContactForm(AbstractEmailForm):
2017-04-12 12:57:37 +02:00
intro = RichTextField(default='', blank=True)
thanks = RichTextField(default='', blank=True)
2017-04-08 15:47:10 +02:00
content_panels = AbstractEmailForm.content_panels + [
2017-04-12 12:57:37 +02:00
FieldPanel('intro', classname="full"),
FieldPanel('thanks', classname="full"),
2017-04-08 15:47:10 +02:00
InlinePanel('form_fields', label="Form fields"),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('from_address', classname="col6"),
FieldPanel('to_address', classname="col6"),
]),
FieldPanel('subject'),
], "Email"),
]
2017-04-12 00:10:00 +02:00
parent_page_types = ['home.ArticleIndexPage']
2017-04-08 15:47:10 +02:00
class Meta:
verbose_name = "Formular"