Skip to content

Commit

Permalink
feat(v3.6.0): tup 230 make form plugin work (#500)
Browse files Browse the repository at this point in the history
* feat(tup-230): working form plugin

* docs(tup-230): clarify form submission failure

* feat(tup-230): use jquery version that has ajax

The django-forms(-maintained) plugin expects jquery with ajax features.

Our CMS was using a slim build of jQuery.

The size difference is 17KB, which I consider negligible.

* feat(tup-230): make spam protection available

* feat(tup-230): e-mail template (when e-mail works)

* docs(tup-230): tweak comment in settings

* fix(tup-230): comments & semantic html in template

* fix(tup-230): revert and make some html changes

- less changes form original
- sometimes the original html was better for styling

* feat(tup-230): style form (no design review yet)

Also, no button styling yet.

* chore(tup-230): rename css file, add pointer file

Pointer file mimics what I do for blog CSS, which is also in source.

* docs(tup-230): comment for captcha settings

* fix(tup-230): pin core-styles to v0.3.0

This is before the API change, and the tag just before CMS v3.6.0.

* feat(tup-230): initial button styles

Regarding "--from-future-core-styles":
- Core-Styles with c-button is beyond v0.3.0 at which we are pinned.
- I avoid past v0.3.0, cuz API changed, and I try to limit complexity.

* feat(tup-230):improve & organize field styles

* chore(tup-230): improve proof of captcha override

* chore(tup-230): fix innocuous typos

* feat(tup-230): add & document basic custom captcha

* docs(tup-230): widget template comments cleanup

* fix(tup-230): move field errors to bottom

* fix(tup-230): remove unaltered e-mail template

When we want to customize e-mail, dev should learn template override.

I have to balance how much I help new devs with my own productivity.

* fix(tup-230): template indentation and comments

* chore(tup-230): delete superfluous file

* docs(tup-230): better template comments

* chore(tup-230): remove excess template change

* fix(tup-230): style single checkbox fields on grid

This returns single label and checkbox pair to one line.

* fix(tup-230): tweak single checkbox field grid gap
  • Loading branch information
wesleyboar authored Jun 21, 2022
1 parent eb7c282 commit 938b9b3
Show file tree
Hide file tree
Showing 20 changed files with 713 additions and 37 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"npm": "8.5.5"
},
"devDependencies": {
"@tacc/core-styles": "git+https://git@github.com/TACC/Core-Styles.git",
"@tacc/core-styles": "git+https://git@github.com/TACC/Core-Styles.git#v0.3.0",
"minimist": "^1.2.6",
"node-cmd": "^5.0.0"
},
Expand Down
33 changes: 25 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ djangocms-blog = "1.1.1"
djangocms-bootstrap4 = "2.0.0"
djangocms-column = "1.11.0"
djangocms-file = "3.0.0"
djangocms-forms = "0.2.5"
djangocms-forms-maintained = { git = "https://github.com/avryhof/djangocms-forms", rev = "30f464303d317cf7a3170ad64e11ab4471b4287b" }
djangocms-googlemap = "2.0.0"
djangocms-icon = "2.0.0"
djangocms-link = "3.0.0"
Expand Down
115 changes: 115 additions & 0 deletions taccsite_cms/_settings/form_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""Configure djangocms_forms and related apps"""

from django.utils.translation import gettext_lazy as _

########################
# KNOWN ISSUES
########################

# Unable to export to Excel nor YAML
# (No success hiding those formats from editor)
# https://github.com/avryhof/djangocms-forms/issues/8

########################
# DJANGOCMS_FORMS
# https://github.com/avryhof/djangocms-forms/
########################

# DJANGOCMS_FORMS_PLUGIN_MODULE = ('Generic')
# DJANGOCMS_FORMS_PLUGIN_NAME = ('Form')

# DJANGOCMS_FORMS_TEMPLATES = (
# ('djangocms_forms/form_template/default.html', ('Default')),
# )
DJANGOCMS_FORMS_USE_HTML5_REQUIRED = True

# DJANGOCMS_FORMS_REDIRECT_DELAY = 1000

# The default value is only for test and dev
# DJANGO_FORMS_RECAPTCHA_PUBLIC_KEY = '' # set in Deployments repo, not here
# DJANGO_FORMS_RECAPTCHA_SECRET_KEY = '' # set on sever directly, not here

DJANGOCMS_FORMS_SPAM_PROTECTIONS = (
(0, _('None')),
# (1, _('Honeypot')), # if necessary, learn how to use
(2, _('ReCAPTCHA')),
)
DEFAULT_SPAM_PROTECTION = 0

# Improve form legibility and conceal unavailable features
# https://github.com/avryhof/djangocms-forms/blob/97d7c21/djangocms_forms/cms_plugins.py#L69-L121
DJANGOCMS_FORMS_FIELDSETS = (
(None, {'fields': ('name', 'form_template',),}),
(
_('Text'),
{
'description': _(
'The <strong>Title</strong> and <strong>Description</strong> '
'will display above the input fields and Submit button.'
),
'fields': ('title', 'description','submit_btn_txt',),
},
),
(
None,
{
'description': _(
'You can change the message that appears <em>after</em> someone submits your form. By default, this says "<strong>Thank you!</strong>"'
),
'fields': ('post_submit_msg',),
},
),
(
_('Redirect settings'),
{
'description': _(
'Whether and how to redirect the form <em>after</em> submission.'
),
'fields': ('success_redirect', ('page_redirect', 'external_redirect'), 'redirect_delay',),
}
),
(
_('Submission settings'),
{
'description': 'Whether to save form data.',
'fields': (
'save_data',
'spam_protection',
),
},
),
(
_('Submission e-mail (unavailable feature)'),
{
'classes': ('collapse',),
'description': 'Choose storage options to capture form data. You can enter an e-mail address to which to e-mail form submissions.',
'fields': (
# Submitting form with 'email_to' defined causes server error
# FAQ: We may need to setup some django e-mail server for these
'email_to',
'email_from',
'email_subject',
'email_uploaded_files',
),
},
),
)

########################
# DJANGO
# https://docs.djangoproject.com/en/2.2/ref/settings/#form-renderer
########################

# Allow form template override
# https://github.com/torchbox/django-recaptcha/issues/211#issuecomment-675608391
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'

########################
# DJANGO CMS
########################

_INSTALLED_APPS = [
'djangocms_forms', # form plugin for editors
'django.forms', # support form template override
'captcha', # support recaptcha for djangocms_forms
]
30 changes: 8 additions & 22 deletions taccsite_cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType

from taccsite_cms._settings.form_plugin import *
from taccsite_cms._settings.form_plugin import (
_INSTALLED_APPS as form_plugin_INSTALLED_APPS
)

SECRET_KEY = 'CHANGE_ME'
def gettext(s): return s

Expand Down Expand Up @@ -91,16 +96,6 @@ def gettext(s): return s
GOOGLE_ANALYTICS_PROPERTY_ID = "UA-123ABC@%$&-#"
GOOGLE_ANALYTICS_PRELOAD = True

########################
# CMS FORMS
########################

# Create CMS Forms
# SEE: https://pypi.org/project/djangocms-forms/
# SEE: https://www.google.com/recaptcha/admin/create
DJANGOCMS_FORMS_RECAPTCHA_PUBLIC_KEY = ""
DJANGOCMS_FORMS_RECAPTCHA_SECRET_KEY = ""

########################
# ELASTICSEARCH
########################
Expand Down Expand Up @@ -318,6 +313,9 @@ def gettext(s): return s
'haystack',
'aldryn_apphooks_config',
'test_without_migrations',

] + form_plugin_INSTALLED_APPS + [

'taccsite_cms',
'taccsite_cms.contrib.bootstrap4_djangocms_link',
'taccsite_cms.contrib.bootstrap4_djangocms_picture',
Expand Down Expand Up @@ -415,18 +413,6 @@ def get_subdirs_as_module_names(path):

DJANGOCMS_AUDIO_ALLOWED_EXTENSIONS = ['mp3', 'ogg', 'wav']

# Djangocms Forms Settings.
# SEE: https://github.com/mishbahr/djangocms-forms#configuration
DJANGOCMS_FORMS_PLUGIN_MODULE = ('Generic')
DJANGOCMS_FORMS_PLUGIN_NAME = ('Form')

DJANGOCMS_FORMS_TEMPLATES = (
('djangocms_forms/form_template/default.html', ('Default')),
)
DJANGOCMS_FORMS_USE_HTML5_REQUIRED = False

DJANGOCMS_FORMS_REDIRECT_DELAY = 1

# Elasticsearch Indexing
HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ]
HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor'
Expand Down
3 changes: 3 additions & 0 deletions taccsite_cms/static/css/djangocms_forms/djangocms_forms.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* SEE: ../../site_cms/css/src/app.djangocms_forms.css */
/* FAQ: We use future syntax that often must be processed to work in the now;
and the process does not support outputting files to this directory */
Loading

0 comments on commit 938b9b3

Please sign in to comment.