Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature streamforms #171

Merged
merged 47 commits into from May 16, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3414df4
Integrated Streamforms with our existing form infrastructure.
Apr 29, 2019
0c21511
Moved streamforms. File uploads work correclty now.
Apr 30, 2019
10a3b2d
Integrated the modeladmin for StreamForms.
May 1, 2019
d10e7f4
Cleaned up code.
May 1, 2019
f26952a
Added integration with our stream fields to stream forms. Added fiel…
May 1, 2019
ed5cec5
Fixed missing multiline text input.
May 2, 2019
f404489
Added License for wagtail streamforms
May 2, 2019
4eb65ec
Added progress bar and previous/next button
May 2, 2019
460fd48
Fixed off by one error on Previous butotn.
May 2, 2019
e053aaa
Added extra layer of interaction between coderedcms and wagtail_flexi…
May 4, 2019
e5a2210
Fixed rendering of form submissions files in admin.
May 4, 2019
e6b7579
StreamForm inputs now render custom data attributes and custom settings.
May 4, 2019
f851200
Added template blocks to stream_form_page.html
May 5, 2019
8584baa
Merge
May 5, 2019
d6887a7
Added back newlines
May 5, 2019
5becba8
Started conditional logic js
May 5, 2019
4551ee5
Added docs
May 6, 2019
aececf6
Updated docs.
May 6, 2019
2dfd903
Fixed issue where Anonymous Users weren't getting a session key assig…
May 6, 2019
b31cd2a
Adding conditional logic to front-end
vsalvino May 7, 2019
5aa5104
Merge branch 'feature-streamforms' of github.com:coderedcorp/coderedc…
vsalvino May 7, 2019
d95fe4b
Added logic to create Form Submissions from complete SEssionFormSubmi…
May 7, 2019
babd278
Cleaned up data formatting on csv's.
May 7, 2019
0dc6b12
Added form submission landing page on success for streamform
May 7, 2019
ce5b1f9
Adding dashed line between form fields in summary email
vsalvino May 7, 2019
230b5eb
Merge branch 'feature-streamforms' of github.com:coderedcorp/coderedc…
vsalvino May 7, 2019
eef7deb
Removed print
May 7, 2019
83f7c5d
Removed print
May 7, 2019
5c89bad
Merge branch 'feature-streamforms' of https://github.com/coderedcorp/…
May 7, 2019
30bc9aa
Fixed progress bar
May 7, 2019
2f340c2
Removed - from being shown on blank streamform values.
May 7, 2019
13a9ca9
Added normal dash for null values in stream form submission processing.
May 7, 2019
93b12df
Merge branch 'master' into feature-streamforms
May 13, 2019
b7fa35b
Updated stream form date pickers to use our date picker.
May 13, 2019
3e347ba
Updated docs.
May 13, 2019
d01bba7
Fixed missing links in docs.
May 13, 2019
90f19dd
Fixed hyperlink in docs.
May 13, 2019
6b2c59b
Updated Streamform blocks to use our already existing fields.
May 13, 2019
3d2b9a1
Fixed issue of confirmation emails not rendering links correctly.
May 15, 2019
9c0f7ac
Fixed issue of duplicating fields on submission emails.
May 15, 2019
d30266a
Removed unnecessary line
May 15, 2019
c39da67
Merge
May 15, 2019
85f0be0
Updated tests for Streamforms.
May 15, 2019
789a2c3
Merge branch 'master' into feature-streamforms
May 15, 2019
f401008
Moving js to new coderedms/ dir
vsalvino May 16, 2019
16f5d47
Updating docs
vsalvino May 16, 2019
c841d07
Removing unreachable return
vsalvino May 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 53 additions & 23 deletions coderedcms/blocks/__init__.py
Expand Up @@ -5,49 +5,54 @@
"""

from django.utils.translation import ugettext_lazy as _
from wagtail.core.blocks import CharBlock, StreamBlock, StructBlock

from coderedcms.wagtail_flexible_forms.blocks import FormStepBlock, FormStepsBlock
Copy link
Contributor

@vsalvino vsalvino May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my concern here is that this will potentially cause migrations from hell once we have to switch to built-in wagtail streamforms. I'm wondering if we should wrap/extend any blocks or concrete models in wagtail_flexible_forms, that way all the migrations are pointing to our models, and we can update under the hood as necessary. I only say that because a similar thing happened when we switched from wagtail's built-in RichTextBlock to our own RichTextBlock, and I had to do a bunch of find&replace in migration files in client projects to resolve.

I'm not 100% sure if it will cause problems or not, just trying to be proactive. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoderedAdvancedFormPage uses the extended CoderedFormStepBlock which inherits from their FormStepBlock. All of our File Fields are using extended versions of their file fields. The only thing that we might want to do related to this concern is to only use wff as a library and extend their StreamFormMixin and Step/Steps classes in the CMS so there is no direct contact between the CMS and wff.


from .advanced_form_blocks import * #noqa
from .base_blocks import * #noqa
from .html_blocks import * #noqa
from .metadata_blocks import * #noqa
from .content_blocks import * #noqa
from .layout_blocks import * #noqa



# Collections of blocks commonly used together.

HTML_STREAMBLOCKS = [
('text', RichTextBlock(icon='fa-file-text-o')),
('button', ButtonBlock()),
('image', ImageBlock()),
('image_link', ImageLinkBlock()),
('html', blocks.RawHTMLBlock(icon='code', classname='monospace', label=_('HTML'))),
('download', DownloadBlock()),
('embed_video', EmbedVideoBlock()),
('quote', QuoteBlock()),
('table', TableBlock()),
('google_map', EmbedGoogleMapBlock()),
('page_list', PageListBlock()),
('page_preview', PagePreviewBlock()),
('text', RichTextBlock(icon='fa-file-text-o', group=_('HTML'))),
('button', ButtonBlock(group=_('HTML'))),
('image', ImageBlock(group=_('HTML'))),
('image_link', ImageLinkBlock(group=_('HTML'))),
('html', blocks.RawHTMLBlock(icon='code', classname='monospace', label=_('HTML'), group=_('HTML'))),
('download', DownloadBlock(group=_('HTML'))),
('embed_video', EmbedVideoBlock(group=_('HTML'))),
('quote', QuoteBlock(group=_('HTML'))),
('table', TableBlock(group=_('HTML'))),
('google_map', EmbedGoogleMapBlock(group=_('HTML'))),
('page_list', PageListBlock(group=_('HTML'))),
('page_preview', PagePreviewBlock(group=_('HTML'))),
]

CONTENT_STREAMBLOCKS = HTML_STREAMBLOCKS + [
('card', CardBlock()),
('carousel', CarouselBlock()),
('image_gallery', ImageGalleryBlock()),
('modal', ModalBlock(HTML_STREAMBLOCKS)),
('pricelist', PriceListBlock()),
('reusable_content', ReusableContentBlock()),
('card', CardBlock(group=_('Content'))),
('carousel', CarouselBlock(group=_('Content'))),
('image_gallery', ImageGalleryBlock(group=_('Content'))),
('modal', ModalBlock(HTML_STREAMBLOCKS, group=_('Content'))),
('pricelist', PriceListBlock(group=_('Content'))),
('reusable_content', ReusableContentBlock(group=_('Content'))),
]

NAVIGATION_STREAMBLOCKS = [
('page_link', NavPageLinkWithSubLinkBlock()),
('external_link', NavExternalLinkWithSubLinkBlock()),
('document_link', NavDocumentLinkWithSubLinkBlock()),
('page_link', NavPageLinkWithSubLinkBlock(group=_('Navigation'))),
('external_link', NavExternalLinkWithSubLinkBlock(group=_('Navigation'))),
('document_link', NavDocumentLinkWithSubLinkBlock(group=_('Navigation'))),
]

BASIC_LAYOUT_STREAMBLOCKS = [
('row', GridBlock(HTML_STREAMBLOCKS)),
('html', blocks.RawHTMLBlock(icon='code', classname='monospace', label=_('HTML'))),
('row', GridBlock(HTML_STREAMBLOCKS, group=('Layout'))),
('html', blocks.RawHTMLBlock(icon='code', classname='monospace', label=_('HTML'), group=('Layout'))),
]

LAYOUT_STREAMBLOCKS = [
Expand All @@ -64,3 +69,28 @@
),
('html', blocks.RawHTMLBlock(icon='code', classname='monospace', label=_('HTML'))),
]

ADVANCEDFORM_FORMBLOCKS = [
('single_line', CoderedAdvancedFormCharFieldBlock(group=_('Fields'))),
('multi_line', CoderedAdvancedFormTextFieldBlock(group=_('Fields'))),
('number', CoderedAdvancedFormNumberFieldBlock(group=_('Fields'))),
('checkbox', CoderedAdvancedFormCheckboxFieldBlock(group=_('Fields'))),
('radios', CoderedAdvancedFormRadioButtonsFieldBlock(group=_('Fields'))),
('dropdown', CoderedAdvancedFormDropdownFieldBlock(group=_('Fields'))),
('checkboxes', CoderedAdvancedFormCheckboxesFieldBlock(group=_('Fields'))),
('date', CoderedAdvancedFormDateFieldBlock(group=_('Fields'))),
('time', CoderedAdvancedFormTimeFieldBlock(group=_('Fields'))),
('datetime', CoderedAdvancedFormDateTimeFieldBlock(group=_('Fields'))),
('image', CoderedAdvancedFormImageFieldBlock(group=_('Fields'))),
('file', CoderedAdvancedFormFileFieldBlock(group=_('Fields'))),
]


ADVANCEDFORM_STREAMBLOCKS = ADVANCEDFORM_FORMBLOCKS + CONTENT_STREAMBLOCKS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking HTML_STREAMBLOCKS would be a better idea here instead of CONTENT_STREAMBLOCKS, to avoid making the form's streamfield too massive. I don't think it would be good to intermingle form inputs with deeply nested content blocks.


class CoderedAdvancedFormStepBlock(FormStepBlock):
form_fields = StreamBlock(ADVANCEDFORM_STREAMBLOCKS)


class CoderedAdvancedFormStepsBlock(FormStepsBlock):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like defining classes here in this __init__ file, does not seem consistent with our structure. Do you think these classes could be moved into their own file or into the advanced_form_blocks file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would get a circular dependency error if it was in advanced_form_blocks.py as we need the Content/HTML block list to build the CoderedAdvancedFormStepBlock. Alternatively, we can define CoderedAdvancedFormStepBlock in advanced_form_blocks.py but we would have to repeat the Content/HTML block list in that file.

step = CoderedAdvancedFormStepBlock()
88 changes: 88 additions & 0 deletions coderedcms/blocks/advanced_form_blocks.py
@@ -0,0 +1,88 @@
from django.utils.translation import ugettext_lazy as _
from wagtail.core import blocks


from coderedcms.wagtail_flexible_forms import blocks as form_blocks
from coderedcms.blocks.base_blocks import BaseBlock, CoderedAdvSettings
from coderedcms.forms import SecureFileField


class CoderedFormAdvSettings(CoderedAdvSettings):

conditional_name = blocks.CharBlock(
required=False,
max_length=255,
label=_('Conditional Name'),
help_text=_('The name used to identify this block for other blocks to target as a condition.')
)
conditional_target_name = blocks.CharBlock(
required=False,
max_length=255,
label=_('Conditional Target Name'),
help_text=_('The name of the block that will be this block\'s condition.')
)
conditional_target_value = blocks.CharBlock(
required=False,
max_length=255,
label=_('Conditional Target Value'),
help_text=_('The value of this block\'s condition that is required to show this block on the form.')
)


class FormBlockMixin(BaseBlock):
class Meta:
abstract=True

advsettings_class = CoderedFormAdvSettings


class CoderedAdvancedFormFieldBlock(form_blocks.OptionalFormFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormCharFieldBlock(form_blocks.CharFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormTextFieldBlock(form_blocks.TextFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormNumberFieldBlock(form_blocks.NumberFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormCheckboxFieldBlock(form_blocks.CheckboxFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormRadioButtonsFieldBlock(form_blocks.RadioButtonsFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormDropdownFieldBlock(form_blocks.DropdownFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormCheckboxesFieldBlock(form_blocks.CheckboxesFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormDateFieldBlock(form_blocks.DateFieldBlock, FormBlockMixin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the problem is here, but the Date/Time/Datetime blocks are not rendering with the correct html type="" attribute. They are all showing type="text" and seem to have some additional data attributes added to them. Ideally they would use the HTML5 input types to be consistent with how our current forms work.

pass


class CoderedAdvancedFormTimeFieldBlock(form_blocks.TimeFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormDateTimeFieldBlock(form_blocks.DateTimeFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormImageFieldBlock(form_blocks.ImageFieldBlock, FormBlockMixin):
pass


class CoderedAdvancedFormFileFieldBlock(form_blocks.FileFieldBlock, FormBlockMixin):
field_class = SecureFileField
24 changes: 24 additions & 0 deletions coderedcms/migrations/0015_coderedsessionformsubmission.py
@@ -0,0 +1,24 @@
# Generated by Django 2.2 on 2019-04-30 21:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('wagtail_flexible_forms', '__first__'),
('coderedcms', '0014_classifiers'),
]

operations = [
migrations.CreateModel(
name='CoderedSessionFormSubmission',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('wagtail_flexible_forms.sessionformsubmission',),
),
]
47 changes: 47 additions & 0 deletions coderedcms/migrations/0016_auto_20190501_1322.py

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions coderedcms/migrations/0017_auto_20190502_1122.py

Large diffs are not rendered by default.