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

44 lines
1.3 KiB
Python
Raw Normal View History

2017-04-08 13:47:10 +00:00
# -*- coding: utf-8 -*-
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from django.db.models import CharField
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailforms.models import (
AbstractEmailForm, AbstractFormField
)
2017-04-26 12:06:48 +00:00
from wagtail.wagtailsearch import index
2017-04-08 13:47:10 +00:00
from ..util import TranslatedField
class ContactFormField(AbstractFormField):
page = ParentalKey('ContactForm', related_name='form_fields')
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
2017-04-26 12:06:48 +00:00
search_fields = [ index.SearchField('intro') ]
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"