{ "info": { "author": "VikingCo", "author_email": "technology@vikingco.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "=======================\ndjango-formtools-addons\n=======================\n\n.. image:: https://badge.fury.io/py/django-formtools-addons.png\n :target: https://badge.fury.io/py/django-formtools-addons\n\n.. image:: https://travis-ci.org/vikingco/django-formtools-addons.png?branch=master\n :target: https://travis-ci.org/dirkmoors/django-formtools-addons\n\n'Addons for Django Formtools'\n\nFeatures\n--------\n\n* Add multiple forms to a single WizardView step (MultipleFormWizardView and subclasses)\n* Use form wizard via JSON web API (WizardAPIView)\n\nQuickstart\n----------\n\nInstall formtools-addons::\n\n pip install django-formtools-addons\n\nThen use it in a project::\n\n # Every *MultipleForm* WizardView that can be imported is an equivalent of a builtin *WizardView in Django Formtools\n from formtools_addons import (SessionMultipleFormWizardView, CookieMultipleFormWizardView,\n NamedUrlSessionMultipleFormWizardView, NamedUrlCookieMultipleFormWizardView,\n MultipleFormWizardView, NamedUrlMultipleFormWizardView)\n\n # The WizardAPIView is also based on the builtin WizardView, but does not have the classic request-response cycle,\n # since it exposes a JSON API\n from formtools_addons import WizardAPIView\n\n\nWizardAPIView: Example use\n--------------------------\n\n.. code-block:: python\n\n from __future__ import unicode_literals\n\n from formtools_addons import WizardAPIView\n\n from .forms import Form1, Form2, Form3, Form4\n\n\n def show_substep_4(wizard):\n cleaned_data = wizard.get_cleaned_data_for_step('my-page1|my-substep-1') or {}\n return cleaned_data.get('some_field', None) != 'some_value'\n\n\n class TestWizardAPIView(WizardAPIView):\n form_list = [\n (\"my-page1\", (\n (\"my-substep-1\", Form1),\n (\"my-substep-2\", Form2),\n (\"my-substep-3\", Form3)\n )),\n (\"my-page2\", (\n ('my-substep-4', Form4),\n ))\n ]\n\n condition_dict = {\n 'my-page2|my-substep-4': show_substep_4,\n }\n\n form_templates = {\n \"my-page1|my-substep-1\": 'demo/page1_substep1.html',\n \"my-page2|my-substep-4\": 'demo/page2_substep4.html',\n }\n\n preview_templates = {\n \"my-page1|my-substep-1\": 'demo/page1_substep1_preview.html',\n \"my-page2|my-substep-4\": 'demo/page2_substep4_preview.html',\n }\n\n def render_form(self, step, form):\n # Get preview template url\n template_url = self.form_templates.get(step, None)\n if template_url is None:\n data = form.cleaned_data\n return '
NO TEMPLATE: STEP: %s, DATA: %s
' % (\n step, json.dumps(data, default=self.json_encoder.default))\n\n # Load template\n template = get_template(template_url)\n\n # Create context\n context = Context()\n context['form'] = form\n\n return template.render(context)\n\n def render_preview(self, step, form):\n if not form.is_bound or not form.is_valid():\n return\n\n # Get preview template url\n template_url = self.preview_templates.get(step, None)\n if template_url is None:\n data = form.cleaned_data\n return 'NO TEMPLATE: STEP: %s, DATA: %s
' % (\n step, json.dumps(data, default=self.json_encoder.default))\n\n # Load template\n template = get_template(template_url)\n\n # Create context\n context = Context()\n context['data'] = form.cleaned_data if (form.is_bound and form.is_valid()) else {}\n\n return template.render(context)\n\n ################################################################\n\n # testwizard/urls.py\n\n from __future__ import unicode_literals\n from django.conf.urls import url\n from django.views.decorators.csrf import ensure_csrf_cookie\n\n from .views import TestWizardAPIView\n\n test_wizard = TestWizardAPIView.as_view(url_name='wizard')\n\n urlpatterns = [\n # Registration Wizard API URL's\n url(r'^(?P