From 06536d77a4503a3b87bfc1ca3fe9a23775f3853d Mon Sep 17 00:00:00 2001 From: Eric Theise Date: Sun, 22 Mar 2020 09:13:13 -0600 Subject: [PATCH] feat: first round of work toward #21, implementing survey --- cmdi/settings.py | 1 + cmdi/urls.py | 1 + surveys/__init__.py | 0 surveys/admin.py | 3 + surveys/apps.py | 5 ++ surveys/forms.py | 56 +++++++++++++++++ surveys/migrations/__init__.py | 0 surveys/models.py | 3 + surveys/templates/surveys/base.html | 25 ++++++++ surveys/templates/surveys/header.html | 9 +++ surveys/templates/surveys/index.html | 61 +++++++++++++++++++ .../templates/surveys/svg/chevron-down.svg | 6 ++ surveys/templates/surveys/svg/language.svg | 9 +++ surveys/templates/surveys/svg/location.svg | 3 + surveys/templates/surveys/svg/pcc.svg | 5 ++ surveys/tests.py | 3 + surveys/urls.py | 7 +++ surveys/views.py | 24 ++++++++ 18 files changed, 221 insertions(+) create mode 100644 surveys/__init__.py create mode 100644 surveys/admin.py create mode 100644 surveys/apps.py create mode 100644 surveys/forms.py create mode 100644 surveys/migrations/__init__.py create mode 100644 surveys/models.py create mode 100644 surveys/templates/surveys/base.html create mode 100644 surveys/templates/surveys/header.html create mode 100644 surveys/templates/surveys/index.html create mode 100644 surveys/templates/surveys/svg/chevron-down.svg create mode 100644 surveys/templates/surveys/svg/language.svg create mode 100644 surveys/templates/surveys/svg/location.svg create mode 100644 surveys/templates/surveys/svg/pcc.svg create mode 100644 surveys/tests.py create mode 100644 surveys/urls.py create mode 100644 surveys/views.py diff --git a/cmdi/settings.py b/cmdi/settings.py index ebeb234..f69b164 100644 --- a/cmdi/settings.py +++ b/cmdi/settings.py @@ -72,6 +72,7 @@ 'accounts', 'mdi', 'maps', + 'surveys', 'lockdown', ] diff --git a/cmdi/urls.py b/cmdi/urls.py index f38346f..9822b3d 100644 --- a/cmdi/urls.py +++ b/cmdi/urls.py @@ -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)) diff --git a/surveys/__init__.py b/surveys/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/surveys/admin.py b/surveys/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/surveys/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/surveys/apps.py b/surveys/apps.py new file mode 100644 index 0000000..861dd6e --- /dev/null +++ b/surveys/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class SurveysConfig(AppConfig): + name = 'surveys' diff --git a/surveys/forms.py b/surveys/forms.py new file mode 100644 index 0000000..25fd40c --- /dev/null +++ b/surveys/forms.py @@ -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"}) + } + + + diff --git a/surveys/migrations/__init__.py b/surveys/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/surveys/models.py b/surveys/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/surveys/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/surveys/templates/surveys/base.html b/surveys/templates/surveys/base.html new file mode 100644 index 0000000..349618e --- /dev/null +++ b/surveys/templates/surveys/base.html @@ -0,0 +1,25 @@ +{% load static %} + + + + + + {% block title %}{{ title }}{% endblock %} + + + + + + + +{% include 'surveys/header.html' %} +
+
+
+{% block content %}{% endblock %} +
+
+
+{% include 'maps/footer.html' %} + + diff --git a/surveys/templates/surveys/header.html b/surveys/templates/surveys/header.html new file mode 100644 index 0000000..84d58a8 --- /dev/null +++ b/surveys/templates/surveys/header.html @@ -0,0 +1,9 @@ +
+ +
diff --git a/surveys/templates/surveys/index.html b/surveys/templates/surveys/index.html new file mode 100644 index 0000000..9c7ac81 --- /dev/null +++ b/surveys/templates/surveys/index.html @@ -0,0 +1,61 @@ +{% extends 'surveys/base.html' %} +{% load static %} +{% load i18n %} +{% load maps_extras %} +{% block title %}{{ '2020 Ecosystem Survey'|titlify }}{% endblock %} +{% block content %} + +

Do you need funding for your cooperative digital project?

+

No matter at which stage of development, potential funders, the International Cooperative Alliance, and supportive policymakers need to know that you exist!!

+ +

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

+ +

They need to grasp that you matter. FOR THAT, THEY NEED DATA!

+ +

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

+ +

Please help us to help you.

+ +

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.

+ +

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

+ +

+ Our email:
+ info@platform.coop +

+

+ Mail:
+ Institute for the Cooperative Digital Economy
+ The New School
+ 79 5th Avenue, Room 1601
+ New York, NY, 10003
+ USA +

+ +
+
+ {% csrf_token %} +
+ Your contact information +

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.

+
+ {{ user_form }} +
+ +
+
+ About your enterprise or project + {{ organization_form }} +
+ +
+ +
+ +{% endblock %} diff --git a/surveys/templates/surveys/svg/chevron-down.svg b/surveys/templates/surveys/svg/chevron-down.svg new file mode 100644 index 0000000..2373876 --- /dev/null +++ b/surveys/templates/surveys/svg/chevron-down.svg @@ -0,0 +1,6 @@ + diff --git a/surveys/templates/surveys/svg/language.svg b/surveys/templates/surveys/svg/language.svg new file mode 100644 index 0000000..b1dacdb --- /dev/null +++ b/surveys/templates/surveys/svg/language.svg @@ -0,0 +1,9 @@ + diff --git a/surveys/templates/surveys/svg/location.svg b/surveys/templates/surveys/svg/location.svg new file mode 100644 index 0000000..f713f81 --- /dev/null +++ b/surveys/templates/surveys/svg/location.svg @@ -0,0 +1,3 @@ + + + diff --git a/surveys/templates/surveys/svg/pcc.svg b/surveys/templates/surveys/svg/pcc.svg new file mode 100644 index 0000000..ab022aa --- /dev/null +++ b/surveys/templates/surveys/svg/pcc.svg @@ -0,0 +1,5 @@ + diff --git a/surveys/tests.py b/surveys/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/surveys/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/surveys/urls.py b/surveys/urls.py new file mode 100644 index 0000000..88a9cac --- /dev/null +++ b/surveys/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/surveys/views.py b/surveys/views.py new file mode 100644 index 0000000..c99c1de --- /dev/null +++ b/surveys/views.py @@ -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, + })