feat(people): Add nationality and residence fields

See #1
This commit is contained in:
James Graham
2020-02-25 08:38:30 +00:00
parent abcfd67f77
commit 9210636475
6 changed files with 80 additions and 7 deletions

View File

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

View 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),
),
]

View File

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