mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
@@ -164,6 +164,8 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
|||||||
'organisation_started_date',
|
'organisation_started_date',
|
||||||
'project_started_date',
|
'project_started_date',
|
||||||
'job_title',
|
'job_title',
|
||||||
|
'disciplinary_background',
|
||||||
|
'external_organisations',
|
||||||
'latitude',
|
'latitude',
|
||||||
'longitude',
|
'longitude',
|
||||||
]
|
]
|
||||||
@@ -178,6 +180,8 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
|||||||
labels = {
|
labels = {
|
||||||
'project_started_date':
|
'project_started_date':
|
||||||
f'Date started on the {settings.PARENT_PROJECT_NAME} project',
|
f'Date started on the {settings.PARENT_PROJECT_NAME} project',
|
||||||
|
'external_organisations':
|
||||||
|
'Please list the main organisations external to BRECcIA work that you have been working with since 1st January 2019 that are involved in food/water security in African dryland regions'
|
||||||
}
|
}
|
||||||
help_texts = {
|
help_texts = {
|
||||||
'organisation_started_date':
|
'organisation_started_date':
|
||||||
|
|||||||
67
people/migrations/0048_disciplines_and_organisations.py
Normal file
67
people/migrations/0048_disciplines_and_organisations.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Generated by Django 2.2.10 on 2021-03-16 08:14
|
||||||
|
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def forward_disciplines(apps, schema_editor):
|
||||||
|
PersonQuestion = apps.get_model('people', 'PersonQuestion')
|
||||||
|
|
||||||
|
try:
|
||||||
|
question = PersonQuestion.objects.filter(
|
||||||
|
text='Disciplinary background').latest('version')
|
||||||
|
|
||||||
|
PersonAnswerSet = apps.get_model('people', 'PersonAnswerSet')
|
||||||
|
for answerset in PersonAnswerSet.objects.all():
|
||||||
|
answerset.disciplinary_background = ', '.join(
|
||||||
|
answerset.question_answers.filter(question=question).values_list(
|
||||||
|
'text', flat=True))
|
||||||
|
answerset.save()
|
||||||
|
|
||||||
|
question.delete()
|
||||||
|
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def forward_organisations(apps, schema_editor):
|
||||||
|
PersonQuestion = apps.get_model('people', 'PersonQuestion')
|
||||||
|
|
||||||
|
try:
|
||||||
|
question = PersonQuestion.objects.filter(
|
||||||
|
text='Please list the main organisations external to BRECcIA work that you have been working with since 1st January 2019 that are involved in food/water security in African dryland regions'
|
||||||
|
).latest('version')
|
||||||
|
|
||||||
|
PersonAnswerSet = apps.get_model('people', 'PersonAnswerSet')
|
||||||
|
for answerset in PersonAnswerSet.objects.all():
|
||||||
|
answerset.external_organisations = ', '.join(
|
||||||
|
answerset.question_answers.filter(question=question).values_list(
|
||||||
|
'text', flat=True))
|
||||||
|
answerset.save()
|
||||||
|
|
||||||
|
question.delete()
|
||||||
|
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('people', '0047_remove_personanswerset_external_organisations'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='personanswerset',
|
||||||
|
name='disciplinary_background',
|
||||||
|
field=models.CharField(blank=True, help_text='Research discipline(s) you feel most affiliated with', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.RunPython(forward_disciplines),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='personanswerset',
|
||||||
|
name='external_organisations',
|
||||||
|
field=models.CharField(blank=True, max_length=1023),
|
||||||
|
),
|
||||||
|
migrations.RunPython(forward_organisations),
|
||||||
|
]
|
||||||
@@ -169,6 +169,17 @@ class PersonAnswerSet(AnswerSet):
|
|||||||
blank=True,
|
blank=True,
|
||||||
null=False)
|
null=False)
|
||||||
|
|
||||||
|
disciplinary_background = models.CharField(
|
||||||
|
help_text='Research discipline(s) you feel most affiliated with',
|
||||||
|
max_length=255,
|
||||||
|
blank=True,
|
||||||
|
null=False)
|
||||||
|
|
||||||
|
#: Organisations worked with which aren't in the Organisations list
|
||||||
|
external_organisations = models.CharField(max_length=1023,
|
||||||
|
blank=True,
|
||||||
|
null=False)
|
||||||
|
|
||||||
#: Latitude for displaying location on a map
|
#: Latitude for displaying location on a map
|
||||||
latitude = models.FloatField(blank=True, null=True)
|
latitude = models.FloatField(blank=True, null=True)
|
||||||
|
|
||||||
@@ -203,7 +214,8 @@ class PersonAnswerSet(AnswerSet):
|
|||||||
|
|
||||||
answers = {
|
answers = {
|
||||||
# Foreign key fields have _id at end in model _meta but don't in forms
|
# Foreign key fields have _id at end in model _meta but don't in forms
|
||||||
field.attname.rstrip('_id'): field_value_repr(field)
|
# str.rstrip strips a set of characters, not a suffix, so doesn't work here
|
||||||
|
field.attname.rsplit('_id')[0]: field_value_repr(field)
|
||||||
for field in self._meta.get_fields()
|
for field in self._meta.get_fields()
|
||||||
if field.attname not in exclude_fields
|
if field.attname not in exclude_fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@
|
|||||||
<tr><td>Job Title</td><td>{{ answer_set.job_title }}</td></tr>
|
<tr><td>Job Title</td><td>{{ answer_set.job_title }}</td></tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if answer_set.disciplinary_background %}
|
||||||
|
<tr><td>Disciplinary Background</td><td>{{ answer_set.disciplinary_background }}</td></tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if answer_set.external_organisations %}
|
||||||
|
<tr><td>External Organisations Worked With</td><td>{{ answer_set.external_organisations }}</td></tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for question, answers in question_answers.items %}
|
{% for question, answers in question_answers.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ question }}</td>
|
<td>{{ question }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user