mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -87,10 +87,16 @@ class OrganisationAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
||||
class Meta:
|
||||
model = models.OrganisationAnswerSet
|
||||
fields = [
|
||||
'name',
|
||||
'website',
|
||||
'countries',
|
||||
'hq_country',
|
||||
'latitude',
|
||||
'longitude',
|
||||
]
|
||||
widgets = {
|
||||
'countries': Select2MultipleWidget(),
|
||||
'hq_country': Select2Widget(),
|
||||
'latitude': forms.HiddenInput,
|
||||
'longitude': forms.HiddenInput,
|
||||
}
|
||||
|
||||
34
people/migrations/0041_add_static_org_questions.py
Normal file
34
people/migrations/0041_add_static_org_questions.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 2.2.10 on 2021-03-05 11:53
|
||||
|
||||
from django.db import migrations, models
|
||||
import django_countries.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0040_person_organisation_relationship_targets'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='organisationanswerset',
|
||||
name='countries',
|
||||
field=django_countries.fields.CountryField(blank=True, help_text='Geographical spread - in which countries does this organisation have offices? Select all that apply', max_length=746, multiple=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='organisationanswerset',
|
||||
name='hq_country',
|
||||
field=django_countries.fields.CountryField(blank=True, help_text='In which country does this organisation have its main location?', max_length=2),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='organisationanswerset',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='organisationanswerset',
|
||||
name='website',
|
||||
field=models.URLField(blank=True, max_length=255),
|
||||
),
|
||||
]
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from .question import AnswerSet, Question, QuestionChoice
|
||||
|
||||
@@ -60,10 +61,28 @@ class OrganisationAnswerSet(AnswerSet):
|
||||
blank=False,
|
||||
null=False)
|
||||
|
||||
#: Latitude for displaying location on a map
|
||||
name = models.CharField(max_length=255, blank=True, null=False)
|
||||
|
||||
website = models.URLField(max_length=255, blank=True, null=False)
|
||||
|
||||
#: Which countries does this organisation operate in?
|
||||
countries = CountryField(
|
||||
multiple=True,
|
||||
blank=True,
|
||||
null=False,
|
||||
help_text=(
|
||||
'Geographical spread - in which countries does this organisation '
|
||||
'have offices? Select all that apply'))
|
||||
|
||||
#: Which country is this organisation based in?
|
||||
hq_country = CountryField(
|
||||
blank=True,
|
||||
null=False,
|
||||
help_text=(
|
||||
'In which country does this organisation have its main location?'))
|
||||
|
||||
latitude = models.FloatField(blank=True, null=True)
|
||||
|
||||
#: Longitude for displaying location on a map
|
||||
longitude = models.FloatField(blank=True, null=True)
|
||||
|
||||
#: Answers to :class:`OrganisationQuestion`s
|
||||
|
||||
@@ -29,7 +29,53 @@
|
||||
|
||||
<hr>
|
||||
|
||||
{% include 'people/person/includes/answer_set_full.html' %}
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Question</th>
|
||||
<th>Answer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% if answer_set.website %}
|
||||
<tr><td>Website</td><td>
|
||||
<a href="{{ answer_set.website }}">{{ answer_set.website }}</a>
|
||||
</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.countries %}
|
||||
<tr><td>Countries</td><td>
|
||||
{% for country in answer_set.countries %}
|
||||
{{ country.name }}{% if not forloop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.hq_country %}
|
||||
<tr><td>HQ Country</td><td>{{ answer_set.hq_country.name }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.is_superuser %}
|
||||
{% for answer in answer_set.question_answers.all %}
|
||||
<tr>
|
||||
<td>{{ answer.question }}</td>
|
||||
<td>{{ answer }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% else %}
|
||||
{% for answer in answer_set.public_answers.all %}
|
||||
<tr>
|
||||
<td>{{ answer.question }}</td>
|
||||
<td>{{ answer }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Last updated: {{ answer_set.timestamp }}</p>
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user