Sparq-Holding-Inc / pulpo-forms-django

Django app for dynamic forms
Apache License 2.0
48 stars 9 forks source link

pulpo-forms-django

Pulpo Forms is a Django app capable of creating powerful surveys with many different field types, multi path logic for fields and pages and statistical analysis of responses.

Requirements

Features

Pulpo Forms provides several useful functionalities and characteristics for survey creation.

Demo

http://demo.pulpoforms.octobot.io/pulpo/

User: pulpo Password: pulpo123

Getting Started

Installation

Install Pulpo Forms with the Python package manager:

    pip install pulpo-forms

Settings

Pulpo Forms supports adding the items of models of other applications as combobox options. This is called ModelField. For this to work it is necessary to define a new field type. that extends the abstract class ModelField and which sets the model attribute to the model class whose items shall be shown.

Note:

It is not yet supported to filter these items. It should also have a JavaScript constructor class but just needs to redefine the properties.html template to show the correct name.

Rendering forms

To render the forms you should use the Pulpo Forms Angular directive

Fields

Field components

Each of the field types that belong to this framework has the following components:

Python class

Each field type must have a Python class. This class must extend the abstract class Field (implemented in pulpo_forms.fieldtypes.Field.py) or one of its subclasses. This class will contain all the methods associated to this field type like validations, statistics operations, etc. It will also contain the paths to the HTML templates and JavaScript/CSS files associated with this field type.

JavaScript files

Each field type might need up to 3 JavaScript files:

HTML Templates

Each field type must have defined 2 templates which will normally live under templates/fields/<fieldtype_name>/, there is an extra template for fields that have statistics analysis.

Factory

To load all the defined field types dynamically the app uses factories in Front- and Back-End.

This means that for a new field type to be supported, it has to be registered in these factories. Additionally it has to be registered using the same identifying name in both and without using one of the previously used identifiers. Conventionally the identifier will be the same as the class name (e.g. NumberField).

Creating a new field type

To define a new field type you need to create the necessary components detailed in Field Components, and add a line to the settings of your project:

    FIELD_FILES=(
        #other fields,
        <path_to_your_python_class>
    )

Known issues