Skip to content

Commit

Permalink
feat: #21 survey forms & formtools
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Apr 3, 2020
1 parent 4570893 commit 2d2a6f1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 1 deletion.
17 changes: 17 additions & 0 deletions surveys/preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.http import HttpResponseRedirect
from formtools.preview import FormPreview


class IndividualFormPreview(FormPreview):
def done(self, request, cleaned_data):
return HttpResponseRedirect('/form/success')


class OrganizationFormPreview(FormPreview):
def done(self, request, cleaned_data):
return HttpResponseRedirect('/form/success')


class SocialNetworksFormPreview(FormPreview):
def done(self, request, cleaned_data):
return HttpResponseRedirect('/form/success')
3 changes: 3 additions & 0 deletions surveys/static/surveys/css/surveys.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fieldset > label {
line-height: 3rem;
}
1 change: 1 addition & 0 deletions surveys/static/surveys/js/surveys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.getElementsByTagName('label')
8 changes: 8 additions & 0 deletions surveys/templates/surveys/done.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'surveys/base.html' %}
{% load static %}
{% load i18n %}
{% load maps_extras %}
{% block title %}{{ '2020 Ecosystem Survey'|titlify }}{% endblock %}
{% block content %}
<pre>{{ form_data | pprint }}</pre>
{% endblock %}
52 changes: 52 additions & 0 deletions surveys/templates/surveys/individual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% extends 'surveys/base.html' %}
{% load static %}
{% load i18n %}
{% load maps_extras %}
{% block title %}{{ '2020 Ecosystem Survey'|titlify }}{% endblock %}
{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">Platform Co-op</span><br/> Directory</h1>
<p class="subhead">2020 Survey of the International Cooperative Digital Ecosystem</p>
</div>
<h3>Do you need funding for your cooperative digital project?</h3>

<div class="spacer"></div>
Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}
<form action="{% url 'index' %}" method="post">
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
{{ wizard.form }}
{% endif %}

{% csrf_token %}
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<fieldset>
<legend><strong>Your contact information</strong></legend>
<p>Please provide the contact information for the best person to reach out to should we have follow-up questions about the answers you have provided to the short form of our survey. This contact information will not be part of the index. It will not be published online.</p>
<div class="spacer"></div>
{{ individual_form }}
<ul class="input-group">
<strong>{{ role_form.role.label }}</strong>
{% for radio in role_form.role %}
<li>{{ radio.tag }}
<label for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
</li>
{% endfor %}
</ul>

</fieldset>

{% if wizard.steps.prev %}
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
{% endif %}
<input type="submit" value="{% trans "submit" %}"/>

</form>

{% endblock %}
2 changes: 1 addition & 1 deletion surveys/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import views
from .forms import IndividualForm, OrganizationForm, SocialNetworksForm
from .preview import IndividualFormPreview, OrganizationFormPreview, SocialNetworksFormPreview
from .views import SurveyWizard, FORMS, TEMPLATES, ContactWizard
from .views import FORMS, SurveyWizard, ContactWizard


urlpatterns = [
Expand Down

0 comments on commit 2d2a6f1

Please sign in to comment.