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

fixes django cms 3 compatibility #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FormDesignerPlugin(CMSPluginBase):
name = _('Form')
admin_preview = False
render_template = False
cache = False

def render(self, context, instance, placeholder):
if instance.form_definition.form_template_name:
Expand All @@ -22,7 +23,7 @@ def render(self, context, instance, placeholder):
self.render_template = settings.DEFAULT_FORM_TEMPLATE

# Redirection does not work with CMS plugin, hence disable:
return process_form(context['request'], instance.form_definition, context, disable_redirection=True)
return process_form(context['request'], instance.form_definition, context, disable_redirection=True, push_messages=False)


plugin_pool.register_plugin(FormDesignerPlugin)
8 changes: 5 additions & 3 deletions form_designer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
designedform_error, designedform_render)


def process_form(request, form_definition, extra_context={}, disable_redirection=False):
def process_form(request, form_definition, extra_context={}, disable_redirection=False, push_messages=True):
context = extra_context
success_message = form_definition.success_message or _('Thank you, the data was submitted successfully.')
error_message = form_definition.error_message or _('The data could not be submitted, please try again.')
Expand All @@ -41,7 +41,8 @@ def process_form(request, form_definition, extra_context={}, disable_redirection
files = handle_uploaded_files(form_definition, form)

# Successful submission
messages.success(request, success_message)
if push_messages:
messages.success(request, success_message)
form_success = True

designedform_success.send(sender=process_form, context=context,
Expand All @@ -59,7 +60,8 @@ def process_form(request, form_definition, extra_context={}, disable_redirection
form_error = True
designedform_error.send(sender=process_form, context=context,
form_definition=form_definition, request=request)
messages.error(request, error_message)
if push_messages:
messages.error(request, error_message)
else:
if form_definition.allow_get_initial:
form = DesignedForm(form_definition, initial_data=request.GET)
Expand Down