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

41 lines
1.2 KiB
Python
Raw Normal View History

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