feat: Add date started at organisation

See #33
This commit is contained in:
James Graham
2020-06-24 15:09:23 +01:00
parent 26bf55b4b4
commit ab37139429
4 changed files with 40 additions and 0 deletions

View File

@@ -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):

View File

@@ -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'),
),
]

View File

@@ -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)