From b00ca4c1a2d364bdcc2358229ada5c03d08647cc Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 10 Mar 2021 10:37:42 +0000 Subject: [PATCH] feat: add question on external organisations --- people/forms.py | 22 +++++++++++++------ ..._personanswerset_external_organisations.py | 18 +++++++++++++++ people/models/person.py | 5 +++++ .../person/includes/answer_set_full.html | 4 ++++ 4 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 people/migrations/0046_personanswerset_external_organisations.py diff --git a/people/forms.py b/people/forms.py index 4d3b1a4..c82d0bf 100644 --- a/people/forms.py +++ b/people/forms.py @@ -71,13 +71,14 @@ class DynamicAnswerSetBase(forms.Form): if as_filters and question.filter_text: field_label = question.filter_text - field = field_class(label=field_label, - queryset=question.answers, - widget=field_widget, - required=(self.field_required - and not question.allow_free_text), - initial=initial.get(field_name, None), - help_text=question.help_text if not as_filters else '') + field = field_class( + label=field_label, + queryset=question.answers, + widget=field_widget, + required=(self.field_required + and not question.allow_free_text), + initial=initial.get(field_name, None), + help_text=question.help_text if not as_filters else '') self.fields[field_name] = field field_order.append(field_name) @@ -164,6 +165,7 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase): 'organisation_started_date', 'project_started_date', 'job_title', + 'external_organisations', 'latitude', 'longitude', ] @@ -178,12 +180,18 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase): labels = { 'project_started_date': f'Date started on the {settings.PARENT_PROJECT_NAME} project', + 'external_organisations': + (f'Please list the main organisations external to {settings.PARENT_PROJECT_NAME} ' + 'work that you have been working with since 1st January 2019 that are ' + 'involved in food/water security in African dryland regions'), } help_texts = { 'organisation_started_date': 'If you don\'t know the exact date, an approximate date is okay.', 'project_started_date': 'If you don\'t know the exact date, an approximate date is okay.', + 'external_organisations': + 'Please use commas to separate organisation names.', } question_model = models.PersonQuestion diff --git a/people/migrations/0046_personanswerset_external_organisations.py b/people/migrations/0046_personanswerset_external_organisations.py new file mode 100644 index 0000000..311c589 --- /dev/null +++ b/people/migrations/0046_personanswerset_external_organisations.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2021-03-10 10:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('people', '0045_question_help_text'), + ] + + operations = [ + migrations.AddField( + model_name='personanswerset', + name='external_organisations', + field=models.CharField(blank=True, max_length=1023), + ), + ] diff --git a/people/models/person.py b/people/models/person.py index e683127..cf78065 100644 --- a/people/models/person.py +++ b/people/models/person.py @@ -169,6 +169,11 @@ class PersonAnswerSet(AnswerSet): blank=True, null=False) + #: External organisations this person has worked with + external_organisations = models.CharField(max_length=1023, + blank=True, + null=False) + #: Latitude for displaying location on a map latitude = models.FloatField(blank=True, null=True) diff --git a/people/templates/people/person/includes/answer_set_full.html b/people/templates/people/person/includes/answer_set_full.html index 6b2c90d..accb48e 100644 --- a/people/templates/people/person/includes/answer_set_full.html +++ b/people/templates/people/person/includes/answer_set_full.html @@ -31,6 +31,10 @@ Job Title{{ answer_set.job_title }} {% endif %} + {% if answer_set.external_organisations %} + External Organisations Worked With{{ answer_set.external_organisations }} + {% endif %} + {% for answer in answer_set.question_answers.all %} {{ answer.question }}