Skip to content

Commit

Permalink
feat: first round of work toward #21, implementing survey
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Mar 22, 2020
1 parent 28abe91 commit 06536d7
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmdi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
'accounts',
'mdi',
'maps',
'surveys',
'lockdown',
]

Expand Down
1 change: 1 addition & 0 deletions cmdi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# path('accounts/', include('django.contrib.auth.urls')),
url(r'^accounts/', include('allauth.urls')),
path('', include('maps.urls')),
path('surveys/', include('surveys.urls')),
]
urlpatterns += [
path('api/', include(router.urls))
Expand Down
Empty file added surveys/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions surveys/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions surveys/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class SurveysConfig(AppConfig):
name = 'surveys'
56 changes: 56 additions & 0 deletions surveys/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from django.forms import ModelForm, TextInput, Textarea, RadioSelect, DateTimeInput
from django.utils.translation import gettext_lazy as _
from accounts.models import User
from mdi.models import Organization


class UserForm(ModelForm):
class Meta:
model = User
fields = [
'first_name',
'middle_name',
'last_name',
'email',
'role'
]
labels = {
'role': _('Are you a…'),
}
widgets = {
# 'role': RadioSelect()
}


class OrganizationForm(ModelForm):
class Meta:
model = Organization
fields = [
'name',
'url',
'email',
'socialnetworks',
'address',
'city',
'state',
'postal_code',
'country',
'founded',
]
labels = {
'name': _('What is the name of your enterprise or project?'),
'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?'),
'state': _('State or province'),
'founded': _('When was your enterprise or project founded?')
}
help_texts = {
}
widgets = {
'url': TextInput(attrs={'placeholder': 'e.g., https://example.coop/'}),
'founded': DateTimeInput(format="%d/%m/%Y", attrs={'placeholder':"DD/MM/YY"})
}



Empty file added surveys/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions surveys/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
25 changes: 25 additions & 0 deletions surveys/templates/surveys/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% load static %}
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8" />
<title>
{% block title %}{{ title }}{% endblock %}
</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<script src="{% static 'maps/scripts/pinecone.umd.js' %}"></script>
<link href="{% static 'maps/styles/pinecone.css' %}" rel="stylesheet">
<link rel="shortcut icon" href="{% static 'maps/images/favicon.png' %}" type="image/x-icon">
</head>
<body class="home page">
{% include 'surveys/header.html' %}
<div class="wrap container" role="document">
<div class="content">
<main>
{% block content %}{% endblock %}
</main>
</div>
</div>
{% include 'maps/footer.html' %}
</body>
</html>
9 changes: 9 additions & 0 deletions surveys/templates/surveys/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<header role="banner">
<div class="container">
<a class="link link--brand" aria-current="page" href="{% url 'index' %}">
{% include './svg/pcc.svg' %}
<span class="brand__title screen-reader-text">Platform Cooperatives Worldwide</span></a>
<div class="inner">
</div>
</div>
</header>
61 changes: 61 additions & 0 deletions surveys/templates/surveys/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% 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>
<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 />
[email protected]
</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>
<form action="#" method="post">
{% csrf_token %}
<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>
{{ user_form }}
</fieldset>

<div class="spacer"></div>
<fieldset>
<legend><strong>About your enterprise or project</strong></legend>
{{ organization_form }}
</fieldset>

<div class="spacer"></div>
<button id="button" type="submit" class="button">
<span class="button__label">{% trans "Submit" %}</span>
</button>
</form>

{% endblock %}
6 changes: 6 additions & 0 deletions surveys/templates/surveys/svg/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions surveys/templates/surveys/svg/language.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions surveys/templates/surveys/svg/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions surveys/templates/surveys/svg/pcc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions surveys/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions surveys/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from . import views

urlpatterns = [
path('', views.index, name='index'),
]
24 changes: 24 additions & 0 deletions surveys/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.http import HttpResponse, HttpResponseRedirect
from django.template import loader
from django.shortcuts import get_object_or_404, render

from .forms import UserForm, OrganizationForm

from accounts.models import User
from mdi.models import Organization, Category, Sector, Type


def index(request):
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
return HttpResponseRedirect('/thanks/')

else:
user_form = UserForm()
organization_form = OrganizationForm()

return render(request, 'surveys/index.html', {
'user_form': user_form,
'organization_form': organization_form,
})

0 comments on commit 06536d7

Please sign in to comment.