Skip to content

Commit

Permalink
Ajout champ Nationalité
Browse files Browse the repository at this point in the history
  • Loading branch information
davy39 committed Jan 23, 2022
1 parent 22c5160 commit 6d2b727
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions inscription/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self, *args, **kwargs):
'departement_naissance',
'commune_naissance',
'date_naissance',
'nationalite',
'address',
'telephone',
'photo',
Expand Down Expand Up @@ -121,7 +122,7 @@ class Meta:
# Modèle utilisé et entrées à renseigner
model = BaseEleve
fields = ['address', 'civility', 'genre', 'nom', 'prenom', 'nom_usage', 'date_naissance', 'pays_naissance',
'photo', 'commune_naissance', 'departement_naissance', 'telephone', 'email', 'confirmation_email']
'photo', 'commune_naissance', 'departement_naissance', 'telephone', 'email', 'confirmation_email', 'nationalite']
# Ajout d'un date picker au format='%Y-%m-%d' pour qu'il affiche les valeurs initiales lors des update
# https://stackoverflow.com/questions/58294769/django-forms-dateinput-not-populating-from-instance
widgets = {
Expand All @@ -130,7 +131,9 @@ class Meta:
'commune_naissance': autocomplete.ModelSelect2(url='linked_data',
forward=('departement_naissance',)),
'departement_naissance': autocomplete.ModelSelect2(url='departement'),
'pays_naissance': autocomplete.ModelSelect2(url='pays')
'pays_naissance': autocomplete.ModelSelect2(url='pays'),
'nationalite': autocomplete.ModelSelect2(url='pays'),

}

class Media:
Expand Down
1 change: 1 addition & 0 deletions inscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __iter__(self):
commune_naissance = models.ForeignKey(Commune, on_delete=models.CASCADE, verbose_name="Commune de naissance")
departement_naissance = models.ForeignKey(Departement, on_delete=models.CASCADE, verbose_name="Département de naissance")
pays_naissance = models.ForeignKey(Pays, on_delete=models.CASCADE, verbose_name="Pays de naissance")
nationalite = models.ForeignKey(Pays, on_delete=models.CASCADE, verbose_name="Nationalité", related_name='nationalite',)
address = AddressField(verbose_name="Adresse", related_name='eleve')
civility = models.CharField(max_length=3, choices=CIVILITY_CHOICES, default='M.', verbose_name="Civilité",
help_text="Quel sexe t'est attribué dans les documents administratifs ?")
Expand Down
20 changes: 20 additions & 0 deletions migrations/inscription/0004_baseeleve_nationalite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0 on 2022-01-23 20:21

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('inscription', '0003_remove_baseeleve_type_resp1_and_more'),
]

operations = [
migrations.AddField(
model_name='baseeleve',
name='nationalite',
field=models.ForeignKey(default='100', on_delete=django.db.models.deletion.CASCADE, related_name='nationalite', to='inscription.pays', verbose_name='Nationalité'),
preserve_default=False,
),
]

0 comments on commit 6d2b727

Please sign in to comment.