Skip to content

Commit

Permalink
feat: addresses #17 & #21, revising survey
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Apr 9, 2020
1 parent 41bdf05 commit dfccf31
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 226 deletions.
1 change: 0 additions & 1 deletion maps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def manage_socialnetworks(request, user_id):
# Profile flow
# This trivially branches to either the Organization or Individual Profile `django-formtools` wizard.
def profile(request):
print(request.POST)
if request.method == 'POST':
if request.POST['type'] == 'org':
return redirect('organization-profile')
Expand Down
53 changes: 43 additions & 10 deletions surveys/forms.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
from django import forms
from django.forms import TextInput, ModelForm, RadioSelect, CheckboxSelectMultiple, DateTimeInput, URLInput, modelformset_factory
from django.forms import RadioSelect, CheckboxSelectMultiple, DateTimeInput, HiddenInput, URLInput, formset_factory
from django.utils.translation import gettext_lazy as _
from django.template.defaultfilters import safe
from accounts.models import User, Role
from mdi.models import Organization, Sector, SocialNetwork
from mdi.models import Organization, OrganizationSocialNetwork, Sector, SocialNetwork


class IndividualForm(forms.Form):
class BaseForm(forms.Form):
def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '') # globally override the Django >=1.6 default of ':'
super(BaseForm, self).__init__(*args, **kwargs)


class BaseModelForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '') # globally override the Django >=1.6 default of ':'
super(BaseModelForm, self).__init__(*args, **kwargs)


class ContactInfoForm(BaseForm):
first_name = forms.CharField(max_length=254, required=False)
middle_name = forms.CharField(max_length=254,required=False)
last_name = forms.CharField(max_length=254, required=False)
email = forms.EmailField(max_length=254, label='Email address')
role = forms.ChoiceField(choices=enumerate(Role.objects.all()), label='Are you/is this person a…', widget=RadioSelect(attrs={'class': 'radio'}))
role = forms.ModelMultipleChoiceField(
queryset=Role.objects.all(),
label=safe('Are you/is this person a…'),
widget=CheckboxSelectMultiple(attrs={'class': 'checkbox'})
)


class OrganizationForm(ModelForm):
class BasicOrganizationInfoForm(BaseModelForm):
class Meta:
model = Organization
fields = [
Expand All @@ -34,6 +51,7 @@ class Meta:
'url': _('What is the URL of your enterprise or project?'),
'email': _('What is the general contact email address for your enterprise or project?'),
'socialnetworks': _('What are the social media handles of your enterprise or project?'),
'address': _(safe('What is the physical address of the headquarters of your enterprise or project?<br/> Street')),
'state': _('State or province'),
'founded': _('When was your enterprise or project founded?'),
'media_url': _('Paste a link to photos or any introductory video about your enterprise or project:'),
Expand All @@ -49,7 +67,7 @@ class Meta:
}


class SocialNetworksForm(ModelForm):
class SocialNetworksForm(BaseModelForm):
class Meta:
model = SocialNetwork
fields = [
Expand All @@ -58,7 +76,7 @@ class Meta:
]


class LegalStatusForm(ModelForm):
class LegalStatusForm(BaseModelForm):
class Meta:
model = Organization
fields = [
Expand All @@ -72,7 +90,7 @@ class Meta:
}


class StageForm(ModelForm):
class StageForm(BaseModelForm):
class Meta:
model = Organization
fields = [
Expand All @@ -86,7 +104,7 @@ class Meta:
}


class CategoryForm(ModelForm):
class CategoryForm(BaseModelForm):
class Meta:
model = Organization
fields = [
Expand All @@ -100,7 +118,7 @@ class Meta:
}


class SectorForm(ModelForm):
class SectorForm(BaseModelForm):
class Meta:
model = Organization
fields = [
Expand All @@ -112,3 +130,18 @@ class Meta:
widgets = {
'sectors': CheckboxSelectMultiple(attrs={'class': 'checkbox'})
}


class OrganizationSocialNetworkForm(BaseModelForm):
class Meta:
model = OrganizationSocialNetwork
fields = [
'socialnetwork',
'identifier',
]
widgets = {
'socialnetwork': HiddenInput(),
}


OrganizationSocialNetworkFormSet = formset_factory(OrganizationSocialNetworkForm, extra=0)
17 changes: 0 additions & 17 deletions surveys/preview.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<link rel="shortcut icon" href="{% static 'maps/images/favicon.png' %}" type="image/x-icon">
</head>
<body class="home page">
{% include 'surveys/header.html' %}
{% include 'surveys/ecosystem_2020/header.html' %}
<div class="wrap container" role="document">
<div class="content">
<main>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends 'surveys/ecosystem_2020/base.html' %}
{% load static %}
{% load i18n %}
{% load maps_extras %}
{% block title %}{{ 'Basic Organization Information'|titlify }}{% endblock %}
{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">2020 Ecosystem Survey </span><br/> Basic Organization Information</h1>
</div>
<form action="" method="post">
{% csrf_token %}
{% if form.errors %}
{{ form.errors }}
{% endif %}
{{ wizard.management_form }}
{% include 'maps/profiles/back_and_steps.html' %}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
<fieldset>
<legend><strong>Basic organization information</strong></legend>
<div class="spacer"></div>
{{ wizard.form }}
<div class="spacer"></div>
</fieldset>
{% endif %}

{% include 'maps/profiles/footer.html' %}
</form>

{% endblock %}
54 changes: 54 additions & 0 deletions surveys/templates/surveys/ecosystem_2020/contact_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends 'surveys/ecosystem_2020/base.html' %}
{% load static %}
{% load i18n %}
{% load maps_extras %}
{% block title %}{{ 'Contact Information'|titlify }}{% endblock %}
{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">2020 Ecosystem Survey </span><br/> Contact Information</h1>
</div>
<form action="" method="post">
{% csrf_token %}
{% if form.errors %}
{{ form.errors }}
{% endif %}
{{ wizard.management_form }}
{% include 'maps/profiles/back_and_steps.html' %}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
<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>
<label for="{{ wizard.form.first_name.id_for_label }}">
{{ wizard.form.first_name.label }}{{ wizard.form.first_name }}
</label>
<label for="{{ wizard.form.middle_name.id_for_label }}">
{{ wizard.form.middle_name.label }}{{ wizard.form.middle_name }}
</label>
<label for="{{ wizard.form.last_name.id_for_label }}">
{{ wizard.form.last_name.label }}{{ wizard.form.last_name }}
</label>
<label for="{{ wizard.form.email.id_for_label }}">
{{ wizard.form.email.label }}{{ wizard.form.email }}
</label>
<ul class="input-group">
<strong>{{ wizard.form.role.label }}</strong>
{% for checkbox in wizard.form.role %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
</fieldset>
{% endif %}

{% include 'maps/profiles/footer.html' %}
</form>

{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'surveys/base.html' %}
{% extends 'surveys/ecosystem_2020/base.html' %}
{% load static %}
{% load i18n %}
{% load maps_extras %}
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions surveys/templates/surveys/ecosystem_2020/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends 'surveys/ecosystem_2020/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>

<form action="" method="post">
{% csrf_token %}
<h3>Do you need funding for your cooperative digital project?</h3>
<p>No matter at which stage of development, potential funders, the International Cooperative Alliance, and
supportive policymakers need to know that you exist!!</p>

<p>Whether your project just launched or is already fully operational and growing, prospective supporters need to
understand the significance of your project!</p>

<p>They need to grasp that you matter. FOR THAT, THEY NEED DATA!</p>

<p>We need to provide funders and all supporters with reliable information about your project!! Without it, you may
be dismissed and remain invisible.</p>

<p><strong>Please help us to help you.</strong></p>

<p>The survey has been prepared by Prof. Trebor Scholz and Angela Difede at The New School’s Institute for the
Cooperative Digital Economy. Please feel free to contact us directly with any questions.</p>

<p>WE WILL ADD THE INFORMATION THAT YOU PROVIDE HERE TO A *PUBLIC INDEX* ON HTTP://PLATFORM.COOP</p>

<p>
Our email:<br/>
<a rel="external" href="mailto:[email protected]">[email protected]</a>
</p>

<p>
Mail:<br/>
Institute for the Cooperative Digital Economy<br/>
The New School<br/>
79 5th Avenue, Room 1601<br/>
New York, NY, 10003<br/>
USA
</p>

<div class="spacer"></div>
<button id="button" type="submit" class="button">
<span class="button__label">{% trans "Let's begin" %}</span>
</button>

</form>

{% endblock %}
37 changes: 37 additions & 0 deletions surveys/templates/surveys/ecosystem_2020/social_networks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "maps/base.html" %}
{% load static %}
{% load i18n %}
{% load maps_extras %}

{% block title %}{{ 'Social media'|titlify }}{% endblock %}}

{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">Profile Editor</span><br/> Social media</h1>
</div>
<form action="" method="post">
{% csrf_token %}
{% if form.errors %}
{{ form.errors }}
{% endif %}
{{ wizard.management_form }}
{% include 'maps/profiles/back_and_steps.html' %}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
<p><strong>What are the associated social media handles of your enterprise or project?</strong></p>
<div class="spacer"></div>

{% for form in wizard.form.forms %}
<label>{{ form.initial.name }}
{{ form.identifier }}
{{ form.socialnetwork }}
</label>
{% endfor %}
{% else %}

{% endif %}

{% include 'maps/profiles/footer.html' %}
</form>

{% endblock %}
Loading

0 comments on commit dfccf31

Please sign in to comment.