Skip to content

Commit

Permalink
feat: toward #17 & #21, improving survey templates
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed May 5, 2020
1 parent 5184e8a commit 4c541dd
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 79 deletions.
2 changes: 1 addition & 1 deletion maps/templatetags/maps_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
@register.filter(name='titlify')
def titlify(value):
"""Prepends value and emdash to base title"""
title_base = 'Platform Cooperatives Worldwide'
title_base = 'Platform Cooperativism Consortium'
return value + ' – ' + title_base
19 changes: 19 additions & 0 deletions mdi/migrations/0062_auto_20200505_0225.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.0.3 on 2020-05-05 02:25

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('mdi', '0061_organization_tools'),
]

operations = [
migrations.AlterField(
model_name='organization',
name='stage',
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='mdi.Stage'),
),
]
2 changes: 1 addition & 1 deletion mdi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Organization(models.Model):
related_organizations = models.ManyToManyField('self', through='EntitiesEntities')
# num_impacted = models.IntegerField(blank=True)
categories = models.ManyToManyField(Category, blank=True,)
stage = models.ForeignKey(Stage, blank=True, null=True, on_delete=models.CASCADE)
stage = models.ForeignKey(Stage, blank=True, null=True, default=None, on_delete=models.CASCADE)
source = models.ForeignKey(Source, on_delete=models.CASCADE, blank=True, null=True)
type = models.ForeignKey(Type, on_delete=models.CASCADE, blank=True, null=True)
sectors = models.ManyToManyField(Sector, blank=True,)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"build:css": "cp maps/static/maps/css/app.css maps/static/maps/dist/css/site.css",
"copy:fonts": "cp maps/static/maps/fonts/* maps/static/maps/dist/fonts/",
"copy:images": "cp -r maps/static/maps/images/* maps/static/maps/dist/images/ 2>/dev/null || :",
"optimize:js": "uglifyjs maps/static/maps/dist/js/site.js -m -c warnings=false -o maps/static/maps/dist/js/site.js",
"optimize:js": "uglifyjs maps/static/maps/dist/js/site.js -m -c -o maps/static/maps/dist/js/site.js",
"optimize:css": "cssnano maps/static/maps/dist/css/site.css maps/static/maps/dist/css/site.css",
"optimize": "npm run optimize:js",
"build:js": "browserify -t [ babelify ] -t envify maps/static/maps/js/index.js | uglifyjs -c warnings=false -o maps/static/maps/dist/js/site.js",
"build:js": "browserify -t [ babelify ] -t envify maps/static/maps/js/index.js | uglifyjs -c -o maps/static/maps/dist/js/site.js",
"watch:lint": "onchange maps/static/maps/js/*.js -- npm run lint",
"watch:css": "onchange maps/static/maps/css/* -- npm run build:css",
"lint": "eslint maps/static/maps/js/*.js",
Expand Down
10 changes: 8 additions & 2 deletions surveys/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
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, OrganizationSocialNetwork, Sector, SocialNetwork
from mdi.models import Organization, OrganizationSocialNetwork, Sector, SocialNetwork, Stage


class BaseForm(forms.Form):
error_css_class = 'error'
required_css_class = 'required'

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):
error_css_class = 'error'
required_css_class = 'required'

def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '') # globally override the Django >=1.6 default of ':'
super(BaseModelForm, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -88,7 +94,7 @@ class Meta:
widgets = {
'legal_status': CheckboxSelectMultiple(attrs={'class': 'checkbox'}),
'stage': RadioSelect(attrs={'class': 'radio'}),
'challenges': SelectMultiple(attrs={'size': 4, 'class': 'multiple'}),
'challenges': CheckboxSelectMultiple(attrs={'class': 'checkbox'}),
'categories': CheckboxSelectMultiple(attrs={'class': 'checkbox'}),
'sectors': CheckboxSelectMultiple(attrs={'class': 'checkbox'})
}
Expand Down
10 changes: 10 additions & 0 deletions surveys/static/surveys/css/surveys.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ select.multiple {
height: 10rem;
overflow-y: auto;
}

/* Identifying required fields in forms. */
.required {
color: red;
}

label.required::after {
content: ' *';
color: red;
}
4 changes: 2 additions & 2 deletions surveys/templates/surveys/ecosystem_2020/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link href="{% static 'surveys/css/surveys.css' %}" rel="stylesheet">
<link rel="shortcut icon" href="{% static 'maps/images/favicon.png' %}" type="image/x-icon">
</head>
<body class="home page">
<body class="page">
{% include 'surveys/ecosystem_2020/header.html' %}
<div class="wrap container" role="document">
<div class="content">
Expand All @@ -21,6 +21,6 @@
</main>
</div>
</div>
{% include 'maps/footer.html' %}
{% include 'surveys/ecosystem_2020/footer.html' %}
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% 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>
<h1>Basic Organization Information</h1>
</div>
<form action="" method="post">
{% csrf_token %}
Expand Down
134 changes: 73 additions & 61 deletions surveys/templates/surveys/ecosystem_2020/categories_challenges.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,88 @@
{% load maps_extras %}
{% block title %}{{ 'Categories & Challenges'|titlify }}{% endblock %}
{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">2020 Ecosystem Survey </span><br/> Categories & Challenges</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>Incorporation</strong></legend>
<ul class="input-group">
<strong>{{ wizard.form.legal_status.label }}</strong>
{% for checkbox in wizard.form.legal_status %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
</fieldset>
<div class="page-header">
<h1>Categories & Challenges</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>Incorporation</strong></legend>
<ul class="input-group">
<strong>{{ wizard.form.legal_status.label }}</strong>
{% for checkbox in wizard.form.legal_status %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
</fieldset>
<div class="spacer"></div>

<fieldset>
<legend><strong>Development stage and challenges</strong></legend>
<ul class="input-group">
<strong>{{ wizard.form.stage.label }}</strong>
{% for radio in wizard.form.stage %}
<fieldset>
<legend><strong>Development stage and challenges</strong></legend>
<ul class="input-group">
<strong>{{ wizard.form.stage.label }}</strong>
{% for radio in wizard.form.stage %}
{% if radio.choice_label != '---------' %}
<li>{{ radio.tag }}
<label for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
<label for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
{% endif %}
{% endfor %}
</ul>
<div class="spacer"></div>

<ul class="input-group">
<strong>{{ wizard.form.challenges.label }}</strong>
{{ wizard.form.challenges }}
</fieldset>
{% for checkbox in wizard.form.challenges %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>

<div class="spacer"></div>
</fieldset>
<div class="spacer"></div>

<ul class="input-group">
<strong>{{ wizard.form.categories.label }}</strong>
{% for checkbox in wizard.form.categories %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
<div class="spacer"></div>
<ul class="input-group">
<strong>{{ wizard.form.sectors.label }}</strong>
{% for checkbox in wizard.form.sectors %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
<fieldset>
<legend><strong>Terms and Sectors</strong></legend>
<ul class="input-group">
<strong>{{ wizard.form.categories.label }}</strong>
{% for checkbox in wizard.form.categories %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>
<ul class="input-group">
<strong>{{ wizard.form.sectors.label }}</strong>
{% for checkbox in wizard.form.sectors %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
</li>
{% endfor %}
</ul>
<div class="spacer"></div>

</fieldset>
{% endif %}
</fieldset>
{% endif %}

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

{% endblock %}
8 changes: 4 additions & 4 deletions surveys/templates/surveys/ecosystem_2020/contact_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% 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>
<h1>Contact Information</h1>
</div>
<form action="" method="post">
{% csrf_token %}
Expand Down Expand Up @@ -34,10 +34,10 @@ <h1><span class="pc-ff--sans pc-fw--normal">2020 Ecosystem Survey </span><br/> C
{{ 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>
{{ wizard.form.email.label }}<span class="required"> *</span></label>{{ wizard.form.email }}

<ul class="input-group">
<strong>{{ wizard.form.role.label }}</strong>
<strong>{{ wizard.form.role.label }}</strong><span class="required"> *</span>
{% for checkbox in wizard.form.role %}
<li>{{ checkbox.tag }}
<label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label>
Expand Down
47 changes: 47 additions & 0 deletions surveys/templates/surveys/ecosystem_2020/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% load static %}
<footer class="content-info">
<div class="container">
<div class="columns">
<div class="column">
<a class="logo link--inverse" rel="external" href="https://platform.coop/">
<svg class="logo__image" viewBox="0 0 282.08 78.75" aria-hidden="true" focusable="false">
<use href="{% static 'maps/images/logo.svg#logo' %}" />
</svg>
<span class="screen-reader-text">Platform Cooperativism Consortium</span>
</a>
<div class="nav">
<p><a class="link--inverse" href="https://platform.coop/open-access-and-privacy-policy/">Our Open Access & Privacy Policy</a></p>
<p><a class="link--inverse" href="https://platform.coop/diversity-inclusion/">Our Commitment to Diversity and Inclusion</a></p>
</div>
</div>
<div class="column">
<div class="h4"><a rel="external" class="link--inverse" href="https://platform.coop/contact-us/">Contact us</a></div>
<div>
<strong>Email</strong><br>
<a class="link--inverse" href="mailto:[email protected]" rel="external">[email protected]</a>
</div>
</div>
</div>
</div>
</footer>
<script src="{% static 'maps/dist/js/site.js' %}"></script>
<script>
const menu = document.querySelector('.menu');
const menuToggle = document.querySelector('.menu-toggle');

if (menu && menuToggle) {
new Pinecone.Menu(menu, menuToggle);
}

const icons = document.querySelectorAll( 'svg' );
if (icons) {
Array.prototype.forEach.call(icons, icon => {
new Pinecone.Icon(icon);
});
}

const searchToggle = document.querySelector('.search-toggle');
if (searchToggle) {
new Pinecone.SearchToggle(searchToggle, searchToggle.nextElementSibling);
}
</script>
5 changes: 3 additions & 2 deletions surveys/templates/surveys/ecosystem_2020/header.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{% load static %}
<header role="banner">
<div class="container">
<a class="link link--brand" aria-current="page" href="{% url 'index' %}">
<a class="link link--brand" aria-current="page" href="#">
<svg class="icon icon--pcc icon--lg" viewBox="0 0 32 32" aria-hidden="" focusable="">
<use href="{% static 'maps/images/pcc.svg#pcc' %}" />
</svg>
<span class="brand__title screen-reader-text">Platform Cooperatives Worldwide</span></a>
<span class="brand__title screen-reader-text">2020 Survey of the International Cooperative Digital Ecosystem</span></a>
<div class="inner">
2020 Survey of the International Cooperative Digital Ecosystem
</div>
</div>
</header>
5 changes: 3 additions & 2 deletions surveys/templates/surveys/ecosystem_2020/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
{% 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 class="inside">
<h1>Welcome</h1>
</div>
</div>

<form action="" method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block content %}
<div class="page-header">
<h1><span class="pc-ff--sans pc-fw--normal">2020 Ecosystem Survey </span><br/> Social media</h1>
<h1>Social media</h1>
</div>
<form action="" method="post">
{% csrf_token %}
Expand Down

0 comments on commit 4c541dd

Please sign in to comment.