├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.txt ├── MANIFEST.in ├── Makefile ├── README.md ├── cmsplugin_forms_builder ├── __init__.py ├── cms_plugins.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_update_related_name.py │ └── __init__.py ├── models.py ├── south_migrations │ ├── 0001_initial.py │ └── __init__.py └── tests.py ├── manage.py ├── requirements.txt ├── sample └── templates │ └── forms │ └── includes │ └── built_form.html ├── screenshots ├── readme.png └── readme2.png ├── setup.py └── tests ├── __init__.py ├── settings.py └── urls.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.egg 3 | *.egg-info 4 | *.sublime-project 5 | *.sublime-workspace 6 | htmlcov 7 | _build 8 | .coverage 9 | .DS_Store -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | python: 4 | - '2.7' 5 | env: 6 | global: 7 | - NIFTY_TRAVIS_CACHE_REPO=https://github.com/nimbis/travis-cache-public.git 8 | install: 9 | - pip install --upgrade setuptools 10 | - make reqs 11 | before_script: 12 | - git clone https://github.com/nimbis/nifty.git ./.nifty 13 | script: 14 | - source .nifty/nifty-script 15 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to this project! We ask that you 4 | please follow a few guidelines in order to have your changes reviewed and 5 | merged quickly: 6 | 7 | * Base your pull requests against the `master` branch. 8 | * Make commits of logical units. For example, a commit to refactor existing 9 | code should be separate from a commit to add a new feature. 10 | * Check for unnecessary whitespace with `git diff --check` before committing. 11 | * Include descriptive commit messages for each commit that detail what 12 | was changed and why. 13 | * Include any necessary tests for your changes. 14 | * Ensure that any existing tests have not been broken by your changes. 15 | * Ensure any Python code changes pass [pep8](https://github.com/PyCQA/pep8) and [flake8](https://gitlab.com/pycqa/flake8). 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Nimbis Services, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the Nimbis Services nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | include LICENSE.txt 3 | recursive-include requirements *.txt 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: travis-tests test pep8 clean coverage doc check-venv 3 | 4 | # clean out potentially stale pyc files 5 | clean: 6 | @find . -name "*.pyc" -exec rm {} \; 7 | 8 | # check that virtualenv is enabled 9 | check-venv: 10 | ifndef VIRTUAL_ENV 11 | $(error VIRTUAL_ENV is undefined, try "workon" command) 12 | endif 13 | 14 | # Install pip requirements.txt file 15 | reqs: check-venv 16 | pip install -r requirements.txt 17 | 18 | PEP8_OPTS=--repeat --exclude=static,migrations,south_migrations,js,doc --show-source 19 | pep8: 20 | pycodestyle $(PEP8_OPTS) . 21 | 22 | # 23 | # flake8 24 | # 25 | 26 | FLAKE8_OPTS=--exclude=static,migrations,south_migrations,js,doc,travis_* 27 | flake8: check-venv 28 | flake8 $(FLAKE8_OPTS) . 29 | 30 | # 31 | # unit tests 32 | # 33 | 34 | test: check-venv clean 35 | ./manage.py test 36 | 37 | # 38 | # code coverage 39 | # 40 | 41 | COVERAGE_ARGS=--source=cmsplugin_forms_builder --omit=cmsplugin_forms_builder/tests.py 42 | coverage: 43 | coverage erase 44 | -coverage run $(COVERAGE_ARGS) ./manage.py test 45 | coverage report 46 | coverage html 47 | @echo "See ./htmlcov/index.html for coverage report" 48 | 49 | # 50 | # TravisCI 51 | # 52 | 53 | travis-tests: check-venv 54 | @echo "travis_fold:start:flake8" 55 | make flake8 56 | @echo "travis_fold:end:flake8" 57 | 58 | @echo "travis_fold:start:pip_freeze" 59 | pip freeze -l 60 | @echo "travis_fold:end:pip_freeze" 61 | 62 | coverage erase 63 | @echo "travis_fold:start:test" 64 | coverage run $(COVERAGE_ARGS) ./manage.py test --keepdb -v 2 65 | @echo "travis_fold:end:test" 66 | 67 | @echo "travis_fold:start:coverage" 68 | coverage report 69 | coverage html 70 | @echo "travis_fold:end:coverage" 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmsplugin-forms-builder 2 | 3 |  4 | 5 |  6 | 7 | ### A [django-forms-builder](https://github.com/stephenmcd/django-forms-builder) plugin for [django-cms](https://github.com/divio/django-cms) 8 | 9 | [](https://travis-ci.org/nimbis/cmsplugin-forms-builder) 10 | 11 | This plugin provides a simple means of inserting django-forms-builder forms 12 | as django-cms plugins. You will need to override django-forms-builder's default `built_form.html` [template](https://github.com/stephenmcd/django-forms-builder/blob/master/forms_builder/forms/templates/forms/includes/built_form.html) in your project in order to POST the form using AJAX, which is then handled appropriately by django-forms-builder's built in views. See the sample [template](https://github.com/nimbis/cmsplugin-forms-builder/blob/master/sample/templates/forms/includes/built_form.html) for a better idea of how this works. 13 | 14 | 15 | ## Requires 16 | 17 | * django >= 1.8 18 | * django-cms >= 3.3.1 19 | * django-forms-builder 20 | 21 | 22 | ## Setup 23 | 24 | * Verify django-cms and django-forms-builder are installed correctly. 25 | 26 | * Run `pip install cmsplugin-forms-builder` or download this package and run `python setup.py install` 27 | 28 | * Add `'forms_builder.forms', 'cmsplugin_forms_builder'` to your project's INSTALLED_APPS. 29 | 30 | * In order to submit your django-forms-builder forms via AJAX, you will need to override django-forms-builder's default `built_form.html` template. Since everyone's use case is different, this repository does not come with a predefined template in order to work "out-of-the-box". However, a sample [template](https://github.com/nimbis/cmsplugin-forms-builder/blob/master/sample/templates/forms/includes/built_form.html) is provided to help you get started. 31 | 32 | Contributing 33 | ------------ 34 | 35 | See the [Contributing Guidelines](CONTRIBUTING.md). 36 | 37 | 38 | ## History 39 | 40 | v1.1.1 (March 29, 2018): 41 | 42 | * Organize the plugin in the admin UI with other form plugins. 43 | * Display a useful string description of forms in the admin UI. 44 | 45 | v1.1.0 (September 8, 2016): 46 | 47 | * Adding migration required for Django CMS v3.3.1 and later, which is now 48 | required for this app. 49 | 50 | v1.0.1: 51 | 52 | * Include README.md in the manifest. 53 | 54 | v1.0.0: 55 | 56 | * Removed unnecessary code in views.py and urls.py. 57 | * Improved documentation in README 58 | * Added screenshots and sample `build_form.html` template 59 | * Fixed setup.py, no longer requires pip>=6.0 60 | * Loosened requirements slightly 61 | 62 | v0.1.11: 63 | 64 | * Update to Django 1.7 migrations 65 | 66 | v0.1.4: 67 | 68 | * Fixed bug on Safari browser, make sure that 'cmsplugin_forms_builder' comes 69 | above 'forms_builder.forms' in INSTALLED_APPS 70 | 71 | v0.1.1: 72 | 73 | * Fixed bugs related to imports in views.py 74 | 75 | v0.1.0: 76 | 77 | * Initial commit 78 | -------------------------------------------------------------------------------- /cmsplugin_forms_builder/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/cmsplugin_forms_builder/__init__.py -------------------------------------------------------------------------------- /cmsplugin_forms_builder/cms_plugins.py: -------------------------------------------------------------------------------- 1 | from cms.plugin_base import CMSPluginBase 2 | from cms.plugin_pool import plugin_pool 3 | from cmsplugin_forms_builder.models import PluginForm 4 | from django.utils.translation import ugettext_lazy as _ 5 | 6 | 7 | class FormBuilderPlugin(CMSPluginBase): 8 | """ 9 | Plugin class for form-builder forms. 10 | """ 11 | 12 | module = _("Forms") 13 | model = PluginForm 14 | name = _("Form") 15 | render_template = "forms/form_detail.html" 16 | cache = False 17 | 18 | def render(self, context, instance, placeholder): 19 | context['form'] = instance.form 20 | return context 21 | 22 | 23 | plugin_pool.register_plugin(FormBuilderPlugin) 24 | -------------------------------------------------------------------------------- /cmsplugin_forms_builder/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('cms', '__first__'), 11 | ('forms', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='PluginForm', 17 | fields=[ 18 | ('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)), 19 | ('form', models.ForeignKey(to='forms.Form', on_delete=models.CASCADE)), 20 | ], 21 | options={ 22 | 'abstract': False, 23 | }, 24 | bases=('cms.cmsplugin',), 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /cmsplugin_forms_builder/migrations/0002_update_related_name.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import migrations, models 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('cmsplugin_forms_builder', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='pluginform', 16 | name='cmsplugin_ptr', 17 | field=models.OneToOneField(parent_link=True, related_name='cmsplugin_forms_builder_pluginform', auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /cmsplugin_forms_builder/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/cmsplugin_forms_builder/migrations/__init__.py -------------------------------------------------------------------------------- /cmsplugin_forms_builder/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from cms.models.pluginmodel import CMSPlugin 3 | from forms_builder.forms.models import Form 4 | 5 | 6 | class PluginForm(CMSPlugin): 7 | """ 8 | Model for the plugin form. 9 | """ 10 | 11 | form = models.ForeignKey(Form, on_delete=models.CASCADE) 12 | 13 | def __str__(self): 14 | return self.form.title 15 | -------------------------------------------------------------------------------- /cmsplugin_forms_builder/south_migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from south.utils import datetime_utils as datetime 3 | from south.db import db 4 | from south.v2 import SchemaMigration 5 | from django.db import models 6 | 7 | 8 | class Migration(SchemaMigration): 9 | 10 | def forwards(self, orm): 11 | # Adding model 'PluginForm' 12 | db.create_table(u'cmsplugin_forms_builder_pluginform', ( 13 | (u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), 14 | ('form', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['forms.Form'])), 15 | )) 16 | db.send_create_signal(u'cmsplugin_forms_builder', ['PluginForm']) 17 | 18 | 19 | def backwards(self, orm): 20 | # Deleting model 'PluginForm' 21 | db.delete_table(u'cmsplugin_forms_builder_pluginform') 22 | 23 | 24 | models = { 25 | 'cms.cmsplugin': { 26 | 'Meta': {'object_name': 'CMSPlugin'}, 27 | 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 28 | 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 29 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 30 | 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), 31 | 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 32 | 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 33 | 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), 34 | 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), 35 | 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), 36 | 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), 37 | 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 38 | 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) 39 | }, 40 | 'cms.placeholder': { 41 | 'Meta': {'object_name': 'Placeholder'}, 42 | 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), 43 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 44 | 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) 45 | }, 46 | u'cmsplugin_forms_builder.pluginform': { 47 | 'Meta': {'object_name': 'PluginForm', '_ormbases': ['cms.CMSPlugin']}, 48 | u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), 49 | 'form': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['forms.Form']"}) 50 | }, 51 | u'forms.form': { 52 | 'Meta': {'object_name': 'Form'}, 53 | 'button_text': ('django.db.models.fields.CharField', [], {'default': "u'Submit'", 'max_length': '50'}), 54 | 'email_copies': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), 55 | 'email_from': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 56 | 'email_message': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 57 | 'email_subject': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), 58 | 'expiry_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 59 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 60 | 'intro': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 61 | 'login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 62 | 'publish_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 63 | 'response': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 64 | 'send_email': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 65 | 'sites': ('django.db.models.fields.related.ManyToManyField', [], {'default': '[1]', 'to': u"orm['sites.Site']", 'symmetrical': 'False'}), 66 | 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}), 67 | 'status': ('django.db.models.fields.IntegerField', [], {'default': '2'}), 68 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) 69 | }, 70 | u'sites.site': { 71 | 'Meta': {'ordering': "(u'domain',)", 'object_name': 'Site', 'db_table': "u'django_site'"}, 72 | 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 73 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 74 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) 75 | } 76 | } 77 | 78 | complete_apps = ['cmsplugin_forms_builder'] -------------------------------------------------------------------------------- /cmsplugin_forms_builder/south_migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/cmsplugin_forms_builder/south_migrations/__init__.py -------------------------------------------------------------------------------- /cmsplugin_forms_builder/tests.py: -------------------------------------------------------------------------------- 1 | from cmsplugin_forms_builder.models import PluginForm 2 | from forms_builder.forms.models import Form 3 | from cms.test_utils.testcases import CMSTestCase 4 | 5 | 6 | class FormTestCase(CMSTestCase): 7 | """ 8 | Simple CRUD test for cmsplugin-forms-builder. 9 | """ 10 | 11 | def setUp(self): 12 | # Create plugin 13 | form = Form.objects.create( 14 | title="Test Form", 15 | slug="testform", 16 | ) 17 | 18 | self.plugin = PluginForm() 19 | self.plugin.form = form 20 | self.plugin.save() 21 | 22 | def test_plugin(self): 23 | 24 | # Read plugin 25 | self.assertEquals(self.plugin.form.title, "Test Form") 26 | self.assertEquals(self.plugin.form.slug, "testform") 27 | 28 | # Update plugin 29 | form = Form.objects.create( 30 | title="New Form", 31 | slug="newform", 32 | ) 33 | 34 | self.plugin.form = form 35 | self.plugin.save() 36 | 37 | self.assertEquals(self.plugin.form.title, "New Form") 38 | self.assertEquals(self.plugin.form.slug, "newform") 39 | 40 | # Delete plugin 41 | self.plugin.delete() 42 | self.plugin = PluginForm.objects.first() 43 | 44 | self.assertEquals(self.plugin, None) 45 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault( 7 | "DJANGO_SETTINGS_MODULE", "tests.settings") 8 | 9 | from django.core.management import execute_from_command_line 10 | 11 | execute_from_command_line(sys.argv) 12 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -e . 2 | 3 | coverage 4 | sphinx 5 | sphinx-rtd-theme 6 | coveralls 7 | flake8 8 | pycodestyle 9 | -------------------------------------------------------------------------------- /sample/templates/forms/includes/built_form.html: -------------------------------------------------------------------------------- 1 | {% load sekizai_tags %} 2 | 3 |
{{ form.intro }}
7 | {% endif %} 8 | 9 | 10 | 11 | 19 | 20 | {% addtoblock 'css' %} 21 | 29 | {% endaddtoblock %} 30 | 31 | {% addtoblock 'js' %} 32 | 77 | {% endaddtoblock 'js' %} 78 | -------------------------------------------------------------------------------- /screenshots/readme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/screenshots/readme.png -------------------------------------------------------------------------------- /screenshots/readme2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/screenshots/readme2.png -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from setuptools import find_packages, setup 4 | 5 | # setup the project 6 | setup( 7 | name='cmsplugin-forms-builder', 8 | version='2.0.0', 9 | description='django-cms plugin for cmsplugin-forms-builder', 10 | long_description=open('README.md').read(), 11 | author='Nimbis Services, Inc.', 12 | author_email='devops@nimbisservices.com', 13 | url='https://github.com/nimbis/cmsplugin-forms-builder/', 14 | packages=find_packages(exclude=["tests", ]), 15 | license='BSD', 16 | classifiers=[ 17 | 'Development Status :: 4 - Beta', 18 | 'Environment :: Web Environment', 19 | 'Intended Audience :: Developers', 20 | 'License :: OSI Approved :: BSD License', 21 | 'Operating System :: OS Independent', 22 | 'Programming Language :: Python', 23 | 'Framework :: Django', 24 | ], 25 | include_package_data=True, 26 | install_requires=[ 27 | 'Django>=2.0, <2.3', 28 | 'django-cms>=3.3.1', 29 | 'django-forms-builder', 30 | ], 31 | zip_safe=False 32 | ) 33 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimbis/cmsplugin-forms-builder/0c123358b64bf73f586182a68a8f09f75d64a31b/tests/__init__.py -------------------------------------------------------------------------------- /tests/settings.py: -------------------------------------------------------------------------------- 1 | DEBUG = True 2 | 3 | ADMINS = ( 4 | # ('Your Name', 'your_email@example.com'), 5 | ) 6 | 7 | MANAGERS = ADMINS 8 | 9 | DATABASES = { 10 | 'default': { 11 | 'ENGINE': 'django.db.backends.sqlite3', 12 | 'NAME': ':memory:', 13 | 'TEST_NAME': ':memory:', 14 | }, 15 | } 16 | 17 | # Hosts/domain names that are valid for this site; required if DEBUG is False 18 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 19 | ALLOWED_HOSTS = [] 20 | 21 | # Local time zone for this installation. Choices can be found here: 22 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 23 | # although not all choices may be available on all operating systems. 24 | # In a Windows environment this must be set to your system time zone. 25 | TIME_ZONE = 'America/Chicago' 26 | 27 | # Language code for this installation. All choices can be found here: 28 | # http://www.i18nguy.com/unicode/language-identifiers.html 29 | LANGUAGE_CODE = 'en-us' 30 | 31 | SITE_ID = 1 32 | 33 | # If you set this to False, Django will make some optimizations so as not 34 | # to load the internationalization machinery. 35 | USE_I18N = True 36 | 37 | # If you set this to False, Django will not format dates, numbers and 38 | # calendars according to the current locale. 39 | USE_L10N = True 40 | 41 | # If you set this to False, Django will not use timezone-aware datetimes. 42 | USE_TZ = True 43 | 44 | # Absolute filesystem path to the directory that will hold user-uploaded files. 45 | # Example: "/var/www/example.com/media/" 46 | MEDIA_ROOT = '' 47 | 48 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 49 | # trailing slash. 50 | # Examples: "http://example.com/media/", "http://media.example.com/" 51 | MEDIA_URL = '' 52 | 53 | # Absolute path to the directory static files should be collected to. 54 | # Don't put anything in this directory yourself; store your static files 55 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 56 | # Example: "/var/www/example.com/static/" 57 | STATIC_ROOT = '' 58 | 59 | # URL prefix for static files. 60 | # Example: "http://example.com/static/", "http://static.example.com/" 61 | STATIC_URL = '/static/' 62 | 63 | # Additional locations of static files 64 | STATICFILES_DIRS = ( 65 | # Put strings here, like "/home/html/static" or "C:/www/django/static". 66 | # Always use forward slashes, even on Windows. 67 | # Don't forget to use absolute paths, not relative paths. 68 | ) 69 | 70 | # List of finder classes that know how to find static files in 71 | # various locations. 72 | STATICFILES_FINDERS = ( 73 | 'django.contrib.staticfiles.finders.FileSystemFinder', 74 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 75 | ) 76 | 77 | # Make this unique, and don't share it with anybody. 78 | SECRET_KEY = '6e-b#&0y4mbwu=)hx7a899p(k+i48(p)@e@^aal8^$pn1xqk$$' 79 | 80 | MIDDLEWARE = [ 81 | 'django.middleware.common.CommonMiddleware', 82 | 'django.contrib.sessions.middleware.SessionMiddleware', 83 | 'django.middleware.csrf.CsrfViewMiddleware', 84 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 85 | 'django.contrib.messages.middleware.MessageMiddleware', 86 | # Uncomment the next line for simple clickjacking protection: 87 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 88 | ] 89 | 90 | ROOT_URLCONF = 'tests.urls' 91 | 92 | # Python dotted path to the WSGI application used by Django's runserver. 93 | WSGI_APPLICATION = 'cmsplugin_forms_builder.wsgi.application' 94 | 95 | TEMPLATES = [ 96 | { 97 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 98 | 'OPTIONS': { 99 | 'debug': DEBUG, 100 | 'context_processors': [ 101 | 'django.core.context_processors.request', 102 | 'django.contrib.auth.context_processors.auth', 103 | 'django.contrib.messages.context_processors.messages', 104 | ], 105 | 'loaders': [ 106 | 'django.template.loaders.filesystem.Loader', 107 | 'django.template.loaders.app_directories.Loader', 108 | ], 109 | }, 110 | }, 111 | ] 112 | 113 | INSTALLED_APPS = ( 114 | 'django.contrib.auth', 115 | 'django.contrib.contenttypes', 116 | 'django.contrib.sessions', 117 | 'django.contrib.sites', 118 | 'django.contrib.messages', 119 | 'django.contrib.staticfiles', 120 | 'menus', 121 | 'treebeard', 122 | 'cms', 123 | 'forms_builder.forms', 124 | 'cmsplugin_forms_builder', 125 | 'django.contrib.admin', 126 | # Uncomment the next line to enable admin documentation: 127 | # 'django.contrib.admindocs', 128 | ) 129 | 130 | # A sample logging configuration. The only tangible logging 131 | # performed by this configuration is to send an email to 132 | # the site admins on every HTTP 500 error when DEBUG=False. 133 | # See http://docs.djangoproject.com/en/dev/topics/logging for 134 | # more details on how to customize your logging configuration. 135 | LOGGING = { 136 | 'version': 1, 137 | 'disable_existing_loggers': False, 138 | 'filters': { 139 | 'require_debug_false': { 140 | '()': 'django.utils.log.RequireDebugFalse' 141 | } 142 | }, 143 | 'handlers': { 144 | 'mail_admins': { 145 | 'level': 'ERROR', 146 | 'filters': ['require_debug_false'], 147 | 'class': 'django.utils.log.AdminEmailHandler' 148 | } 149 | }, 150 | 'loggers': { 151 | 'django.request': { 152 | 'handlers': ['mail_admins'], 153 | 'level': 'ERROR', 154 | 'propagate': True, 155 | }, 156 | } 157 | } 158 | 159 | TEST_RUNNER = 'django.test.runner.DiscoverRunner' 160 | -------------------------------------------------------------------------------- /tests/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | import forms_builder.forms.urls 3 | 4 | from django.contrib import admin 5 | admin.autodiscover() 6 | 7 | urlpatterns = [ 8 | url(r'^admin/', admin.site.urls), 9 | url(r'^forms/', include(forms_builder.forms.urls)), 10 | ] 11 | --------------------------------------------------------------------------------