Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

On request by @tasosalvas - I fixed some bugs #86

Open
wants to merge 22 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
26 changes: 26 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
35 changes: 15 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
================
djangocms-forms
================
==========================
djangocms-forms-maintained
==========================

.. image:: http://img.shields.io/travis/mishbahr/djangocms-forms.svg?style=flat-square
:target: https://travis-ci.org/mishbahr/djangocms-forms/

.. image:: http://img.shields.io/pypi/v/djangocms-forms.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms/
.. image:: http://img.shields.io/pypi/v/djangocms-forms-maintained.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms-maintained/
:alt: Latest Version

.. image:: http://img.shields.io/pypi/dm/djangocms-forms.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms/
.. image:: http://img.shields.io/pypi/dm/djangocms-forms-maintained.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms-maintained/
:alt: Downloads

.. image:: http://img.shields.io/pypi/l/djangocms-forms.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms/
.. image:: http://img.shields.io/pypi/l/djangocms-forms-maintained.svg?style=flat-square
:target: https://pypi.python.org/pypi/djangocms-forms-maintained/
:alt: License

.. image:: http://img.shields.io/coveralls/mishbahr/djangocms-forms.svg?style=flat-square
:target: https://coveralls.io/r/mishbahr/djangocms-forms?branch=master

This project requires django-cms v3.0 or higher to be properly installed and configured.
This project requires django-cms v3.6 or higher to be properly installed and configured.

This package is compatible with `Aldryn <http://www.aldryn.com/en/marketplace/djangocms-forms/>`_.

This version uses https://github.com/praekelt/django-recaptcha for ReCaptcha capabilities.

Quickstart
----------

1. Install ``djangocms-forms``::
1. Install ``djangocms-forms-maintained``::

pip install djangocms-forms
pip install djangocms-forms-maintained

2. Add ``djangocms_forms`` to ``INSTALLED_APPS``::

Expand Down Expand Up @@ -131,8 +126,8 @@ Preview
:align: center


You may also like...
--------------------
You may also like the original author's plugins...
--------------------------------------------------

* djangocms-disqus - https://github.com/mishbahr/djangocms-disqus
* djangocms-embed - https://github.com/mishbahr/djangocms-embed
Expand Down
9 changes: 9 additions & 0 deletions build_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
pip install --upgrade setuptools
pip install --upgrade wheel
pip install --upgrade twine
python setup.py sdist bdist_wheel
# Test PyPi
#twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# Prod PyPi
twine upload dist/*
4 changes: 2 additions & 2 deletions djangocms_forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.2.5'
__version__ = "202004280849"

default_app_config = 'djangocms_forms.apps.DjangoCMSFormsConfig'
default_app_config = "djangocms_forms.apps.DjangoCMSFormsConfig"
4 changes: 2 additions & 2 deletions djangocms_forms/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@


class DjangoCMSFormsConfig(AppConfig):
name = 'djangocms_forms'
verbose_name = _('Forms')
name = "djangocms_forms"
verbose_name = _("Forms")
8 changes: 4 additions & 4 deletions djangocms_forms/cms_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _


class DjangoCMSFormsApphook(CMSApp):
name = _('Forms')
urls = ['djangocms_forms.urls']
name = _("Forms")
urls = ["djangocms_forms.urls"]


apphook_pool.register(DjangoCMSFormsApphook)
155 changes: 86 additions & 69 deletions djangocms_forms/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,34 @@ class FormFieldInline(admin.StackedInline):
extra = 0

formfield_overrides = {
models.TextField: {
'widget': forms.Textarea(
attrs={'rows': 4, 'cols': 50})
},
models.TextField: {"widget": forms.Textarea(attrs={"rows": 4, "cols": 50})},
}

def get_fieldsets(self, request, obj=None):
fields = (
('label', 'field_type', 'required'),
'initial', 'placeholder_text', 'help_text',
'choice_values', 'position',
("label", "field_type", "required"),
"initial",
"placeholder_text",
"help_text",
"choice_values",
"position",
)

if settings.DJANGOCMS_FORMS_ALLOW_CUSTOM_FIELD_NAME:
fields = fields + ('field_name', )
fields = fields + ("field_name",)

fieldsets = (
(None, {
'fields': fields
}),
)
fieldsets = ((None, {"fields": fields}),)
return fieldsets

class Media:
css = {
'all': ('css/djangocms_forms/admin/djangocms_forms.css',)
}
css = {"all": ("css/djangocms_forms/admin/djangocms_forms.css",)}
js = (
'js/djangocms_forms/libs/jquery.min.js',
'js/djangocms_forms/libs/jquery-ui.min.js',

'js/djangocms_forms/admin/jquery-inline-positioning.js',
'js/djangocms_forms/admin/jquery-inline-rename.js',
'js/djangocms_forms/admin/jquery-inline-collapsible.js',
'js/djangocms_forms/admin/jquery-inline-toggle-fields.js',
"js/djangocms_forms/libs/jquery.min.js",
"js/djangocms_forms/libs/jquery-ui.min.js",
"js/djangocms_forms/admin/jquery-inline-positioning.js",
"js/djangocms_forms/admin/jquery-inline-rename.js",
"js/djangocms_forms/admin/jquery-inline-collapsible.js",
"js/djangocms_forms/admin/jquery-inline-toggle-fields.js",
)


Expand All @@ -66,71 +59,95 @@ class FormPlugin(CMSPluginBase):
model = FormDefinition
cache = False
form = FormDefinitionAdminForm
inlines = (FormFieldInline, )
inlines = (FormFieldInline,)
render_template = settings.DJANGOCMS_FORMS_DEFAULT_TEMPLATE

def get_fieldsets(self, request, obj=None):
if settings.DJANGOCMS_FORMS_FIELDSETS:
return settings.DJANGOCMS_FORMS_FIELDSETS

fieldsets = (
(None, {'fields': ('name', )}),

(None, {
'description': _('The <strong>Title</strong> and <strong>Description</strong> '
'will display above the input fields and Submit button.'),
'fields': ('title', 'description', )
}),
(None, {
'description': _('By default, the Submit Button will say <strong>Submit</strong>. '
'You can change this to say whatever you want'),
'fields': ('submit_btn_txt', 'form_template', )
}),
(None, {
'description': _('You can also change the message that appears after someone '
'submits your form. '
'By default, this says <strong>Thank you!</strong>, '
'but you are welcome to change this text as well.'),
'fields': ('post_submit_msg', )
}),
(None, {
'fields': ('success_redirect', ('page_redirect', 'external_redirect'), 'redirect_delay',),
}),
(None, {
'description': '<strong>Submission Settings</strong> &mdash; '
'Choose storage options to capture form data. You can enter '
'an email address to have the form submissions emailed to you or '
'log all the form submissions to the database.',
'fields': ('email_to', 'email_from', 'email_subject',
'email_uploaded_files', 'save_data', 'spam_protection', ),
}),
(None, {"fields": ("name",)}),
(
None,
{
"description": _(
"The <strong>Title</strong> and <strong>Description</strong> "
"will display above the input fields and Submit button."
),
"fields": ("title", "description",),
},
),
(
None,
{
"description": _(
"By default, the Submit Button will say <strong>Submit</strong>. "
"You can change this to say whatever you want"
),
"fields": ("submit_btn_txt", "form_template",),
},
),
(
None,
{
"description": _(
"You can also change the message that appears after someone "
"submits your form. "
"By default, this says <strong>Thank you!</strong>, "
"but you are welcome to change this text as well."
),
"fields": ("post_submit_msg",),
},
),
(None, {"fields": ("success_redirect", ("page_redirect", "external_redirect"), "redirect_delay",),}),
(
None,
{
"description": "<strong>Submission Settings</strong> &mdash; "
"Choose storage options to capture form data. You can enter "
"an email address to have the form submissions emailed to you or "
"log all the form submissions to the database.",
"fields": (
"email_to",
"email_from",
"email_subject",
"email_uploaded_files",
"save_data",
"spam_protection",
),
},
),
)
return fieldsets

def get_render_template(self, context, instance, placeholder):
# returns the first template that exists, falling back to bundled template
return select_template([
instance.form_template,
settings.DJANGOCMS_FORMS_DEFAULT_TEMPLATE,
'djangocms_forms/form_template/default.html'
])
return select_template(
[
instance.form_template,
settings.DJANGOCMS_FORMS_DEFAULT_TEMPLATE,
"djangocms_forms/form_template/default.html",
]
)

def render(self, context, instance, placeholder):
context = super(FormPlugin, self).render(context, instance, placeholder)
request = context['request']
request = context["request"]

form = FormBuilder(
initial={'referrer': request.path_info}, form_definition=instance,
label_suffix='', auto_id='%s')
initial={"referrer": request.path_info}, form_definition=instance, label_suffix="", auto_id="%s"
)

redirect_delay = instance.redirect_delay or \
getattr(settings, 'DJANGOCMS_FORMS_REDIRECT_DELAY', 1000)
redirect_delay = instance.redirect_delay or getattr(settings, "DJANGOCMS_FORMS_REDIRECT_DELAY", 1000)

context.update({
'form': form,
'recaptcha_site_key': settings.DJANGOCMS_FORMS_RECAPTCHA_PUBLIC_KEY,
'redirect_delay': redirect_delay
})
context.update(
{
"form": form,
"recaptcha_site_key": settings.DJANGOCMS_FORMS_RECAPTCHA_PUBLIC_KEY,
"redirect_delay": redirect_delay,
}
)
return context


Expand Down
6 changes: 2 additions & 4 deletions djangocms_forms/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@


class JsonResponse(HttpResponse):

def __init__(self, data, encoder=DjangoJSONEncoder, safe=True, **kwargs):
if safe and not isinstance(data, dict):
raise TypeError('In order to allow non-dict objects to be '
'serialized set the safe parameter to False')
kwargs.setdefault('content_type', 'application/json')
raise TypeError("In order to allow non-dict objects to be " "serialized set the safe parameter to False")
kwargs.setdefault("content_type", "application/json")
data = json.dumps(data, cls=encoder)
super(JsonResponse, self).__init__(content=data, **kwargs)
Loading