Skip to content
Snippets Groups Projects
models.py 1.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • Todd Dembrey's avatar
    Todd Dembrey committed
    from django.db import models
    
    from modelcluster.fields import ParentalKey
    
    
    from wagtail.core.fields import RichTextField
    from wagtail.admin.edit_handlers import (
    
    Todd Dembrey's avatar
    Todd Dembrey committed
        FieldPanel, FieldRowPanel,
        MultiFieldPanel, InlinePanel
    )
    
    from wagtail.contrib.forms.models import AbstractFormField
    from wagtail.search import index
    
    Todd Dembrey's avatar
    Todd Dembrey committed
    
    from wagtailcaptcha.models import WagtailCaptchaEmailForm
    
    
    Todd Dembrey's avatar
    Todd Dembrey committed
    from opentech.public.utils.models import BasePage
    
    Todd Dembrey's avatar
    Todd Dembrey committed
    
    
    class FormField(AbstractFormField):
        page = ParentalKey('FormPage', related_name='form_fields')
    
    
    
    class FormPage(WagtailCaptchaEmailForm, BasePage):
    
    Todd Dembrey's avatar
    Todd Dembrey committed
        subpage_types = []
    
        introduction = models.TextField(blank=True)
        thank_you_text = RichTextField(blank=True, help_text="Text displayed to the user on successful submission of the form")
        action_text = models.CharField(max_length=32, blank=True, help_text="Form action text. Defaults to \"Submit\"")
    
    
        search_fields = BasePage.search_fields + [
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            index.SearchField('introduction'),
        ]
    
    
        content_panels = BasePage.content_panels + [
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            FieldPanel('introduction'),
            InlinePanel('form_fields', label="Form fields"),
            FieldPanel('action_text'),
            FieldPanel('thank_you_text'),
            MultiFieldPanel([
                FieldRowPanel([
                    FieldPanel('from_address', classname="col6"),
                    FieldPanel('to_address', classname="col6"),
                ]),
                FieldPanel('subject'),
            ], "Email"),
        ]