diff --git a/export/serializers/people.py b/export/serializers/people.py index 0174827..4710dc5 100644 --- a/export/serializers/people.py +++ b/export/serializers/people.py @@ -26,6 +26,8 @@ class PersonSerializer(base.FlattenedModelSerializer): 'age_group', 'nationality', 'country_of_residence', + 'organisation', + 'organisation_started_date', ] diff --git a/people/forms.py b/people/forms.py index 1d234f6..267c2c2 100644 --- a/people/forms.py +++ b/people/forms.py @@ -2,6 +2,8 @@ Forms for creating / updating models belonging to the 'people' app. """ from django import forms +from django.forms.widgets import SelectDateWidget +from django.utils import timezone from django_select2.forms import Select2Widget, Select2MultipleWidget @@ -21,6 +23,7 @@ class PersonForm(forms.ModelForm): 'nationality', 'country_of_residence', 'organisation', + 'organisation_started_date', 'job_title', 'discipline', 'role', @@ -31,6 +34,19 @@ class PersonForm(forms.ModelForm): 'country_of_residence': Select2Widget(), 'themes': Select2MultipleWidget(), } + help_texts = { + 'organisation_started_date': + 'If you don\'t know the exact date, an approximate date is okay.', + } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Defaults to showing 10 years in future - show past years instead + num_years_display = 60 + this_year = timezone.datetime.now().year + self.fields['organisation_started_date'].widget = SelectDateWidget( + years=range(this_year, this_year - num_years_display, -1)) class DynamicAnswerSetBase(forms.Form): diff --git a/people/migrations/0020_person_organisation_started_date.py b/people/migrations/0020_person_organisation_started_date.py new file mode 100644 index 0000000..e12a3a9 --- /dev/null +++ b/people/migrations/0020_person_organisation_started_date.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-06-24 12:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('people', '0019_remove_person_core_member'), + ] + + operations = [ + migrations.AddField( + model_name='person', + name='organisation_started_date', + field=models.DateField(null=True, verbose_name='Date started at this organisation'), + ), + ] diff --git a/people/models/person.py b/people/models/person.py index 0854c8a..56c88ea 100644 --- a/people/models/person.py +++ b/people/models/person.py @@ -172,6 +172,10 @@ class Person(models.Model): blank=True, null=True) + #: When did this person start at their current organisation? + organisation_started_date = models.DateField( + 'Date started at this organisation', blank=False, null=True) + #: Job title this person holds within their organisation job_title = models.CharField(max_length=255, blank=True, null=False)