Skip to content

Commit 61dd95d

Browse files
committed
Add: First test
1 parent 6b1a50a commit 61dd95d

17 files changed

+178
-48
lines changed

AUTHORS.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Development Lead
1010
Contributors
1111
------------
1212

13-
None yet. Why not be the first?
13+
* Fabian Braun <[email protected]>
14+

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
0.2.0 (2019-07-18)
7+
++++++++++++++++++
8+
9+
* Add TypeformMixin and TypeformView
10+
611
0.1.0 (2017-10-05)
712
++++++++++++++++++
813

README.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,21 @@ Add it to your `INSTALLED_APPS`:
3636
...
3737
)
3838
39-
Add Django Typeform's static files to your template:
40-
41-
.. code-block:: html
42-
43-
<script src="{% static 'django_typeform/embed.js' %}"></script>
44-
45-
Usage:
39+
Usage as template tag:
4640

4741
.. code-block:: html
4842

4943
{% load django_typeform %}
5044
<html>
5145
<body>
52-
<div class="my-typeform"></div>
53-
<script src="{% static 'django_typeform/embed.js' %}"></script>
54-
{% typeforms_embed 'https://xxxx.typeform.com/to/xxxxxx' '.my-typeform' '{"hideHeaders": true, "hideFooter": true}' %}
46+
{% typeforms_embed 'https://xxxx.typeform.com/to/xxxxxx' 'my-typeform' '{"hideHeaders": true, "hideFooter": true}' %}
5547
</body>
5648
</html>
5749

5850
Features
5951
--------
6052

6153
* Embed SDK Support
54+
* Results API support
55+
* TypeformMixin to use Django forms to process typeform results
56+
* TypeformView to transparently integrate typeforms into the Django framework

django_typeform/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.0'
1+
__version__ = '0.2.0'

django_typeform/static/django_typeform/embed.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/configuration.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=============
2+
Configuration
3+
=============
4+
5+
``django_typeform`` interacts with the Typeform Responses API. To use the
6+
API you need to get a **Personal token** from typeform.
7+
8+
9+
TYPEFORM_TOKEN
10+
..............
11+
12+
The ``TYPEFORM_TOKEN`` setting is **required**. It carries the
13+
personal token of the typeform account. Example:
14+
15+
.. code-block:: python
16+
17+
TYPEFORM_TOKEN = 'heregoesthereallylongtokenstringgiventoyoubytypeform'
18+
19+
Without the token the Responses API will not work and type ``TypeformMixin`` will
20+
not be able to retrieve responses. The template tags are unaffected.
21+
22+

docs/django_typeform.templatetags.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,27 @@ django\_typeform\.templatetags\.django\_typeform module
1313
:show-inheritance:
1414

1515

16-
Module contents
17-
---------------
16+
Template tags
17+
-------------
1818

1919
.. automodule:: django_typeform.templatetags
2020
:members:
2121
:undoc-members:
2222
:show-inheritance:
23+
24+
TypeformMixin
25+
-------------
26+
27+
.. automodule:: django_typeform.forms
28+
:members:
29+
:undoc-members:
30+
:show-inheritance:
31+
32+
TypeformView
33+
------------
34+
35+
.. automodule:: django_typeform.views
36+
:members:
37+
:undoc-members:
38+
:show-inheritance:
39+

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ Contents:
1313

1414
readme
1515
installation
16+
configuration
1617
usage
18+
typeformmixin
19+
typeformview
1720
contributing
1821
authors
1922
history

docs/installation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ Or, if you have virtualenvwrapper installed::
1010

1111
$ mkvirtualenv django-typeform
1212
$ pip install django-typeform
13+
14+
``django_typeform`` requires ``django-sekizai`` to be installed (should happen automatically in the
15+
above instructions). Sekizai is used to position javascript elements at the ebnd of the HTML body.

docs/typeformmixin.rst

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=============
2+
TypeformMixin
3+
=============
4+
5+
The ``TypeformMixin`` is a mixin for Django's form class. To turn
6+
Typeform features on for a Django form just use the Mixin:
7+
8+
.. code-block:: python
9+
10+
from django_typeforms.forms import TypeformMixin
11+
12+
from forms import MyForm
13+
14+
class MyTypeForm(TypeformMixin, MyForm)
15+
typeform_url = 'https://xxxx.typeform.com/to/xxxxxx'
16+
17+
``MyTypeForm`` will be a fully fledge Django form and at the same
18+
time be linked to the Typeform with given url.
19+
20+
For this link to work, the ``Question reference`` for each Typeform
21+
question must be set to the matching Django field name, e.g. ``first_name`` for a
22+
field ``first_name = forms.CharField(max_length=40, blank=True)``. **This requires editiing
23+
all questions of a typeform and as Typeform warns might break
24+
other integrations.**
25+
26+
Additionally, the typeform needs a **hidden field** "typeformuid" which
27+
the ``TypeformMixin`` uses to identify the relevant answer sent to the
28+
Typeform servers. Hidden fields currently are only available to
29+
users of the Typeform PRO and PRO+ plans.
30+
31+
Rendering a typeform
32+
--------------------
33+
34+
Once, a form is turned into a typeform using the mixin, it still can
35+
used and rendered as a Django form using, e.g., ``{{ form }}`` or any
36+
other of your preferred rendering methods.
37+
38+
Additionally, it can be rendered as a typeform using include:
39+
40+
.. code-block:: html
41+
42+
<form method="post">
43+
{% include form with mode='popup' %}
44+
</form>
45+
46+
This will render a hidden input field with a unique id passed to the
47+
typeform's hidden ``typeformuid`` field. Upon completion of
48+
the typeform the above HTML form is posted to the server and
49+
the server can retrieve the answers given by querying the response
50+
with the unique id.
51+
52+
Additional context can be given to the typeform using the ``with`` clause.
53+
54+
Currently, valid context parameters are:
55+
56+
mode
57+
....
58+
``mode`` (default: None) describes the emed mede to be used: ``None`` or ``widget``
59+
for a widget. In widget mode the additional parameter ``height`` is
60+
needed for proper display. Example:
61+
62+
.. code-block:: html
63+
64+
<form method="post">
65+
{% include form with mode='widget' height='100vh' %}
66+
</form>
67+
68+
Other values of ``mode`` can be ``popup``, ``drawer_left``, or
69+
``drawer_right`` which are the three modes for typeform popup modes.
70+
71+
72+
Form validation
73+
---------------
74+
75+
Both Django and Typeform provide form validation. This is prone for conflicts
76+
since both validations need not agree. When turning a Django form into a typeform
77+
we recommend to leave out any validation on the Django side, since for now
78+
there is no way of returning validation errors to typeform.

0 commit comments

Comments
 (0)