mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
@@ -26,6 +26,8 @@ class PersonSerializer(base.FlattenedModelSerializer):
|
||||
'age_group',
|
||||
'nationality',
|
||||
'country_of_residence',
|
||||
'organisation',
|
||||
'organisation_started_date',
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
18
people/migrations/0020_person_organisation_started_date.py
Normal file
18
people/migrations/0020_person_organisation_started_date.py
Normal 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'),
|
||||
),
|
||||
]
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user