Skip to content

Commit

Permalink
Fix example project
Browse files Browse the repository at this point in the history
  • Loading branch information
rense committed Feb 29, 2024
1 parent 170a947 commit 6f86c72
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
6 changes: 3 additions & 3 deletions example/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.fields

import wagtailstreamforms.blocks


Expand All @@ -20,7 +20,7 @@ class Migration(migrations.Migration):
name='BasicPage',
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')),
('body', wagtail.core.fields.StreamField((('rich_text', wagtail.core.blocks.RichTextBlock()), ('form', wagtail.core.blocks.StructBlock((('form', wagtailstreamforms.blocks.FormChooserBlock()), ('form_action', wagtail.core.blocks.CharBlock(help_text='The form post action. "" or "." for the current page or a url', required=False)), ('form_reference', wagtailstreamforms.blocks.InfoBlock(help_text='This form will be given a unique reference once saved', required=False)))))))),
('body', wagtail.fields.StreamField((('rich_text', wagtail.blocks.RichTextBlock()), ('form', wagtail.blocks.StructBlock((('form', wagtailstreamforms.blocks.FormChooserBlock()), ('form_action', wagtail.blocks.CharBlock(help_text='The form post action. "" or "." for the current page or a url', required=False)), ('form_reference', wagtailstreamforms.blocks.InfoBlock(help_text='This form will be given a unique reference once saved', required=False)))))))),
],
options={
'abstract': False,
Expand Down
4 changes: 2 additions & 2 deletions example/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models

from wagtail.admin.panels import StreamFieldPanel
from wagtail import blocks
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.models import Page
from wagtailstreamforms.blocks import WagtailFormBlock
Expand All @@ -23,5 +23,5 @@ class BasicPage(Page):
show_in_menus_default = True

content_panels = Page.content_panels + [
StreamFieldPanel('body'),
FieldPanel('body'),
]
22 changes: 11 additions & 11 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Security

SECRET_KEY = environ.get('SECRET_KEY', '')
SECRET_KEY = environ.get('SECRET_KEY', 's3cr3t')

DEBUG = True

Expand Down Expand Up @@ -38,11 +38,10 @@
'wagtail.contrib.redirects',
'wagtail.sites',
'wagtail_modeladmin',
'wagtail.contrib.postgres_search',
'wagtail.contrib.settings',
'wagtail.contrib.search_promotions',

'captcha',
'django_recaptcha',
'taggit',

# app specific
Expand Down Expand Up @@ -90,14 +89,14 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': environ.get('RDS_HOSTNAME'),
'PORT': environ.get('RDS_PORT'),
'NAME': environ.get('RDS_DB_NAME'),
'USER': environ.get('RDS_USERNAME'),
'PASSWORD': environ.get('RDS_PASSWORD'),
'HOST': environ.get('DB_HOSTNAME'),
'PORT': environ.get('DB_PORT'),
'NAME': environ.get('DB_NAME'),
'USER': environ.get('DB_USERNAME'),
'PASSWORD': environ.get('DB_PASSWORD'),
}
}

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

# Email

Expand Down Expand Up @@ -143,7 +142,7 @@
# Wagtail

WAGTAIL_SITE_NAME = 'example.com'

WAGTAILADMIN_BASE_URL = "/"

# Forms

Expand All @@ -156,4 +155,5 @@
RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
NOCAPTCHA = True
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
SILENCED_SYSTEM_CHECKS = ['django_recaptcha.recaptcha_test_key_error']

2 changes: 1 addition & 1 deletion example/wagtailstreamforms_fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.contrib.auth.models import User
from django_recaptcha.fields import ReCaptchaField

from captcha.fields import ReCaptchaField
from wagtail import blocks
from wagtailstreamforms.fields import BaseField, register

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ psycopg2-binary

# example site
django-recaptcha
wagtail_modeladmin
6 changes: 3 additions & 3 deletions tests/fields/test_streamfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def tearDownClass(cls):
del fields._fields["good"]

def test_child_blocks(self):
field = FormFieldsStreamField([], use_json_field=True)
field = FormFieldsStreamField([])
self.assertIn("good", field.stream_block.child_blocks)

def test_dependencies(self):
field = FormFieldsStreamField([], use_json_field=True)
field = FormFieldsStreamField([])
self.assertListEqual(
[b.__class__ for b in field.stream_block.dependencies],
[b.__class__ for b in field.stream_block.child_blocks.values()],
Expand All @@ -52,6 +52,6 @@ def test_is_invalid_class(self):
)

with self.assertRaises(ImproperlyConfigured) as e:
FormFieldsStreamField([], use_json_field=True)
FormFieldsStreamField([])

self.assertEqual(e.exception.args[0], expected_error)
2 changes: 1 addition & 1 deletion wagtailstreamforms/models/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AbstractForm(models.Model):
template_name = models.CharField(
_("Template"), max_length=255, choices=get_setting("FORM_TEMPLATES")
)
fields = FormFieldsStreamField([], use_json_field=True, verbose_name=_("Fields"))
fields = FormFieldsStreamField([], verbose_name=_("Fields"))
submit_button_text = models.CharField(
_("Submit button text"), max_length=100, default="Submit"
)
Expand Down
4 changes: 2 additions & 2 deletions wagtailstreamforms/streamfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ def dependencies(self):


class FormFieldsStreamField(StreamField):
def __init__(self, block_types, use_json_field=None, **kwargs):
super().__init__(block_types, use_json_field=use_json_field, **kwargs)
def __init__(self, block_types, **kwargs):
super().__init__(block_types, **kwargs)
self.stream_block = FormFieldStreamBlock(block_types, required=not self.blank)

0 comments on commit 6f86c72

Please sign in to comment.