mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -3,6 +3,8 @@ Forms for creating / updating models belonging to the 'people' app.
|
||||
"""
|
||||
from django import forms
|
||||
|
||||
from django_select2.forms import Select2Widget
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
@@ -16,6 +18,10 @@ class PersonForm(forms.ModelForm):
|
||||
'user',
|
||||
'relationship_targets',
|
||||
]
|
||||
widgets = {
|
||||
'nationality': Select2Widget(),
|
||||
'country_of_residence': Select2Widget(),
|
||||
}
|
||||
|
||||
|
||||
class RelationshipForm(forms.ModelForm):
|
||||
|
||||
24
people/migrations/0010_add_country_fields.py
Normal file
24
people/migrations/0010_add_country_fields.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 2.2.10 on 2020-02-24 08:16
|
||||
|
||||
from django.db import migrations
|
||||
import django_countries.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0009_add_first_person_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='person',
|
||||
name='country_of_residence',
|
||||
field=django_countries.fields.CountryField(blank=True, max_length=2, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='person',
|
||||
name='nationality',
|
||||
field=django_countries.fields.CountryField(blank=True, max_length=2, null=True),
|
||||
),
|
||||
]
|
||||
@@ -6,6 +6,8 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from backports.db.models.enums import TextChoices
|
||||
|
||||
|
||||
@@ -70,6 +72,10 @@ class Person(models.Model):
|
||||
age_group = models.CharField(max_length=5,
|
||||
choices=AgeGroupChoices.choices,
|
||||
blank=True, null=False)
|
||||
|
||||
nationality = CountryField(blank=True, null=True)
|
||||
|
||||
country_of_residence = CountryField(blank=True, null=True)
|
||||
|
||||
@property
|
||||
def relationships(self):
|
||||
|
||||
Reference in New Issue
Block a user