Giter Site home page Giter Site logo

wagtail-jotform's Introduction

tests codecov black Total alerts

Wagtail Jotform

Embedable Jotform forms for Wagtail pages.

Wagtail Jotform works by providing a new EmbeddedFormPage page type with a form choice field. Values for this form field are populated from the Jotform API.

Installation

Install from pypi:

pip install wagtail-jotform

Configuration

You will need an API key from Jotform. Add the following variables to your settings:

WAGTAIL_JOTFORM = {
    "API_KEY": "somekey",
    "API_URL": "https://api.jotform.com",
    "LIMIT": 50,
}

LIMIT is the number of results in each result set for form list. Default is 50. Maximum is 1000.

If your Jotform account is in EU safe mode, your JOTFORM_API_URL should be https://eu-api.jotform.com.

Add the following to your INSTALLED_APPS in settings, and note that wagtail_jotform depends on routable_page:

INSTALLED_APPS = [
    ...
    "wagtail_jotform",
    "wagtail.contrib.routable_page",
]

Thank you page

Thank you pages work via Wagtail's RoutablePageMixin.

When a form is created, the Jotform thankurl is set with your created form's thank you page URL, e.g. https://mysite.com/formpage/thank-you. When the form is submitted, the user will be redirected accordingly and be show the 'thank you' data specified on on the form page added.

Overriding templates

Wagtail Jotform has two templates:

  • embedded_form_page.html
  • thank_you.html

You can override these templates in your project by adding them in the following location:

  • your_project_root/
    • templates/
      • wagtail_jotform/
        • embed_form_page.html
        • thank_you.html

Contributing

We welcome contributions to this project. Please follow the contributing instructions to get started.

Release process

To release a new version, the Release documentation should be followed.

wagtail-jotform's People

Contributors

katdom13 avatar kevinhowbrook avatar nickmoreton avatar tomdyson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wagtail-jotform's Issues

Tests

This should definitely have some tests

Add param to thank-you url submitted to jotform

The thank-you url would benefit from being added with a parameter in the jotform side. so the url for the thank you page would be form/thank-you?succes=True or something like that...

This would make it easier to work with analytics and pushing data on successful submissions. Because at the moment any user can request the thank-you page, but with a parameter we could check for that and decide to push js or not

https://github.com/kevinhowbrook/wagtail-jotform/blob/master/wagtail_jotform/wagtail_hooks.py#L10

 thank_you_url = page.full_url + page.specific.reverse_subpage(
            "embedded_form_thank_you"
        )

Increase jotform limit

The default limit of forms fetched from jotform is 20:

Number of results in each result set for form list. Default is 20. Maximum is 1000.

Ideally this should work with a new settings var.

Tasks

Notes on `jot_form_choices()`

def jot_form_choices():
    jot_form_data = []
    if settings.JOTFORM_API_URL and settings.JOTFORM_API_KEY:
        data = JotFormAPI()
        data.fetch_from_api()
        data = data.get_data()

        if data and "content" in data:
            for item in data["content"]:
                jot_form_data.append((item["id"], item["title"]))
    return jot_form_data

Setting data to JotFormAPI then overriding it with the get_data() response is a little confusing, perhaps something like this would read a little easier?

def jot_form_choices():
    jot_form_data = []
    if settings.JOTFORM_API_URL and settings.JOTFORM_API_KEY:
        jotform = JotFormAPI()
        jotform.fetch_from_api()
        data = jotform.get_data()

        if data and "content" in data:
            for item in data["content"]:
                jot_form_data.append((item["id"], item["title"]))
    return jot_form_data

I also think it would be nice if we could skip the if data check by returning an empty dict from the get_data() method. This way the "content" in data is fine on its own.

Manage settings a little more cleanly

wagtail-jotform/wagtail_jotform/settings.py

from django.conf import settings

DEFAULTS = {}


class WagtailJotFormSettings:
    def __getattr__(self, attr):
        django_settings = getattr(settings, "WAGTAIL_JOTFORM", {})

        try:
            # Check if present in user settings
            return django_settings[attr]
        except KeyError:
            return getattr(DEFAULTS, attr, None)

wagtail_jotform_settings = WagtailJotFormSettings()

Then when you define settings in the project they will look like:

WAGTAIL_JOTFORM = {
    "API_KEY": "somevalue",
    "API_URL": "somevalue",
}

And in the app, instead of from django.conf import settings, you can do from .settings import wagtail_jotform_settings
and use that like so:
wagtail_jotform_settings.API_KEY

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.