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

@@ -68,6 +68,8 @@ THIRD_PARTY_APPS = [
'bootstrap4',
'constance',
'constance.backends.database',
'django_countries',
'django_select2',
]
FIRST_PARTY_APPS = [

View File

@@ -38,6 +38,8 @@
{% bootstrap_javascript %}
{% endif %}
{{ form.media.css }}
{% block extra_head %}{% endblock %}
</head>
@@ -155,6 +157,8 @@
{% bootstrap_javascript %}
{% endif %}
{{ form.media.js }}
{% block extra_script %}{% endblock %}
</body>

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
@@ -71,6 +73,10 @@ class Person(models.Model):
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):
return self.relationships_as_source.all().union(

View File

@@ -1,7 +1,38 @@
dj-database-url
django~=2.2
django-bootstrap4
django-constance[database]
django-dbbackup
django-settings-export
python-decouple
astroid==2.3.3
beautifulsoup4==4.8.2
dj-database-url==0.5.0
Django==2.2.10
django-appconf==1.0.3
django-bootstrap4==1.1.1
django-constance==2.6.0
django-countries==5.5
django-dbbackup==3.2.0
django-picklefield==2.1.1
django-select2==7.2.0
django-settings-export==1.2.1
dodgy==0.2.1
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pep8-naming==0.4.1
prospector==1.2.0
pycodestyle==2.4.0
pydocstyle==5.0.2
pyflakes==2.1.1
pylint==2.4.4
pylint-celery==0.3
pylint-django==2.0.12
pylint-flask==0.6
pylint-plugin-utils==0.6
python-decouple==3.3
pytz==2019.3
pyuca==1.2
PyYAML==5.3
requirements-detector==0.6
setoptconf==0.2.0
six==1.14.0
snowballstemmer==2.0.0
soupsieve==1.9.5
sqlparse==0.3.0
typed-ast==1.4.1
wrapt==1.11.2