mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -171,7 +171,7 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
||||
'longitude',
|
||||
]
|
||||
widgets = {
|
||||
'nationality': Select2Widget(),
|
||||
'nationality': Select2MultipleWidget(),
|
||||
'country_of_residence': Select2Widget(),
|
||||
'organisation_started_date': DatePickerInput(format='%Y-%m-%d'),
|
||||
'project_started_date': DatePickerInput(format='%Y-%m-%d'),
|
||||
|
||||
20
people/migrations/0052_allow_multiple_nationalities.py
Normal file
20
people/migrations/0052_allow_multiple_nationalities.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 2.2.10 on 2021-03-19 15:39
|
||||
|
||||
from django.db import migrations
|
||||
import django_countries.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0051_refactor_hardcoded_questions'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='personanswerset',
|
||||
name='nationality',
|
||||
field=django_countries.fields.CountryField(blank=True, default=[], max_length=746, multiple=True),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
@@ -147,7 +147,7 @@ class PersonAnswerSet(AnswerSet):
|
||||
##################
|
||||
# Static questions
|
||||
|
||||
nationality = CountryField(blank=True, null=True)
|
||||
nationality = CountryField(multiple=True, blank=True)
|
||||
|
||||
country_of_residence = CountryField(blank=True, null=True)
|
||||
|
||||
|
||||
@@ -176,8 +176,11 @@ class AnswerSet(models.Model):
|
||||
try:
|
||||
for question in questions:
|
||||
if question.hardcoded_field:
|
||||
question_answers[question.text] = getattr(
|
||||
self, question.hardcoded_field)
|
||||
answer = getattr(self, question.hardcoded_field)
|
||||
if isinstance(answer, list):
|
||||
answer = ', '.join(map(str, answer))
|
||||
|
||||
question_answers[question.text] = answer
|
||||
|
||||
else:
|
||||
answers = self.question_answers.filter(
|
||||
|
||||
Reference in New Issue
Block a user