kopia lustrzana https://github.com/wagtail/wagtail
dont enforce HTML templates :(
rodzic
66a17e6b7d
commit
334bebc55c
|
@ -20,6 +20,7 @@ Changelog
|
|||
* Fix: Prevent empty redirect by overnormalisation (Franklin Kingma, Ludolf Takens)
|
||||
* Fix: "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
||||
* Fix: `RichText` values can now be correctly evaluated as booleans (Mike Dingjan, Bertrand Bordage)
|
||||
* Fix: wagtailforms no longer assumes an .html extension when determining the landing page template filename (kakulukia)
|
||||
|
||||
|
||||
1.5.2 (08.06.2016)
|
||||
|
|
|
@ -148,6 +148,7 @@ Contributors
|
|||
* Oktay Altay
|
||||
* Bertrand Bordage
|
||||
* Paul J Stevens
|
||||
* kakulukia
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -35,6 +35,7 @@ Bug fixes
|
|||
* Prevent empty redirect by overnormalisation
|
||||
* "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
||||
* ``RichText`` values can now be correctly evaluated as booleans (Mike Dingjan, Bertrand Bordage)
|
||||
* wagtailforms no longer assumes an .html extension when determining the landing page template filename (kakulukia)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-06-22 14:59
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import modelcluster.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0029_unicode_slugfield_dj19'),
|
||||
('tests', '0006_sectionedrichtextpage_sectionedrichtextpagesection'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='JadeFormField',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
|
||||
('label', models.CharField(help_text='The label of the form field', max_length=255, verbose_name='label')),
|
||||
('field_type', models.CharField(choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time')], max_length=16, verbose_name='field type')),
|
||||
('required', models.BooleanField(default=True, verbose_name='required')),
|
||||
('choices', models.TextField(blank=True, help_text='Comma separated list of choices. Only applicable in checkboxes, radio and dropdown.', verbose_name='choices')),
|
||||
('default_value', models.CharField(blank=True, help_text='Default value. Comma separated values supported for checkboxes.', max_length=255, verbose_name='default value')),
|
||||
('help_text', models.CharField(blank=True, max_length=255, verbose_name='help text')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='JadeFormPage',
|
||||
fields=[
|
||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||
('to_address', models.CharField(blank=True, help_text='Optional - form submissions will be emailed to this address', max_length=255, verbose_name='to address')),
|
||||
('from_address', models.CharField(blank=True, max_length=255, verbose_name='from address')),
|
||||
('subject', models.CharField(blank=True, max_length=255, verbose_name='subject')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('wagtailcore.page',),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='jadeformfield',
|
||||
name='page',
|
||||
field=modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='form_fields', to='tests.JadeFormPage'),
|
||||
),
|
||||
]
|
|
@ -354,6 +354,26 @@ FormPage.content_panels = [
|
|||
]
|
||||
|
||||
|
||||
# FormPage with a non-HTML extension
|
||||
|
||||
class JadeFormField(AbstractFormField):
|
||||
page = ParentalKey('JadeFormPage', related_name='form_fields')
|
||||
|
||||
|
||||
class JadeFormPage(AbstractEmailForm):
|
||||
template = "tests/form_page.jade"
|
||||
|
||||
JadeFormPage.content_panels = [
|
||||
FieldPanel('title', classname="full title"),
|
||||
InlinePanel('form_fields', label="Form fields"),
|
||||
MultiFieldPanel([
|
||||
FieldPanel('to_address', classname="full"),
|
||||
FieldPanel('from_address', classname="full"),
|
||||
FieldPanel('subject', classname="full"),
|
||||
], "Email")
|
||||
]
|
||||
|
||||
|
||||
# Snippets
|
||||
class AdvertPlacement(models.Model):
|
||||
page = ParentalKey('wagtailcore.Page', related_name='advert_placements')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
@ -34,9 +34,6 @@ FORM_FIELD_CHOICES = (
|
|||
)
|
||||
|
||||
|
||||
HTML_EXTENSION_RE = re.compile(r"(.*)\.html")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class FormSubmission(models.Model):
|
||||
"""Data for a Form submission."""
|
||||
|
@ -139,8 +136,8 @@ class AbstractForm(Page):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(AbstractForm, self).__init__(*args, **kwargs)
|
||||
if not hasattr(self, 'landing_page_template'):
|
||||
template_wo_ext = re.match(HTML_EXTENSION_RE, self.template).group(1)
|
||||
self.landing_page_template = template_wo_ext + '_landing.html'
|
||||
name, ext = os.path.splitext(self.template)
|
||||
self.landing_page_template = name + '_landing' + ext
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.core import mail
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
|
||||
from wagtail.tests.testapp.models import FormField, FormPage
|
||||
from wagtail.tests.testapp.models import FormField, FormPage, JadeFormPage
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailforms.forms import FormBuilder
|
||||
|
@ -718,3 +718,11 @@ class TestIssue585(TestCase):
|
|||
response,
|
||||
text="There is another field with the label foo, please change one of them.",
|
||||
)
|
||||
|
||||
|
||||
class TestNonHtmlExtension(TestCase):
|
||||
fixtures = ['test.json']
|
||||
|
||||
def test_non_html_extension(self):
|
||||
form_page = JadeFormPage(title="test")
|
||||
self.assertEqual(form_page.landing_page_template, "tests/form_page_landing.jade")
|
||||
|
|
Ładowanie…
Reference in New Issue