Skip to content

Commit

Permalink
test InlinlineCheckboxes pour les troubles cognififs
Browse files Browse the repository at this point in the history
  • Loading branch information
Davy39 committed Jan 24, 2022
1 parent 343038c commit d966afe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inscription/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.utils.translation import gettext_lazy as _
from crispy_forms.bootstrap import FormActions, InlineField
from crispy_forms.bootstrap import FormActions, InlineField, InlineCheckboxes
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Div, Fieldset, Layout, Submit
from .models import BaseEleve
Expand Down Expand Up @@ -51,7 +51,6 @@ class InscriptionForm1(forms.ModelForm):
name = 'Identité'
# mail de confirmation
confirmation_email = forms.EmailField(label="Confirmation de l'email", required=False)

def __init__(self, *args, **kwargs):
"""
Surcharge de l'initialisation du formulaire
Expand Down Expand Up @@ -243,12 +242,13 @@ def __init__(self, *args, **kwargs):
self.helper.layout = Layout(
# Liste des champs à afficher dont les champs supplémentaires
'comments',
InlineCheckboxes('dys'),
'captcha',
)

class Meta:
# Définis le modèle utilisé et des données à enregistrer
model = BaseEleve
fields = [
'comments',
'comments', 'dys',
]
10 changes: 10 additions & 0 deletions inscription/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from address.models import AddressField
from multiselectfield import MultiSelectField
from phonenumber_field.modelfields import PhoneNumberField
from .utils import nom_photo, create_hash

Expand Down Expand Up @@ -69,6 +70,7 @@ def __iter__(self):
('elle', 'elle'),
('iel', 'iel')
)

date_naissance = models.DateField(verbose_name="Date de naissance")
commune_naissance = models.ForeignKey(Commune, on_delete=models.CASCADE, verbose_name="Commune de naissance",
blank=True, null=True)
Expand Down Expand Up @@ -121,3 +123,11 @@ def __iter__(self):
sociopro_resp2 = models.ForeignKey(Sociopro, related_name='resp2',
on_delete=models.CASCADE, verbose_name="Profession", blank=True, null=True)

DYS = (
('DL', 'Dyslexie'),
('DC', 'Dyscalculie'),
('DP', 'Dyspraxie'),
('DG', 'Dysgraphie'),
('DO', 'Dysorthographie')
)
dys = MultiSelectField(choices=DYS,verbose_name='Troubles cognitifs', blank=True, null=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.0 on 2022-01-24 20:10

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


class Migration(migrations.Migration):

dependencies = [
('inscription', '0004_baseeleve_nationalite'),
]

operations = [
migrations.AddField(
model_name='baseeleve',
name='dys',
field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('DL', 'Dyslexie'), ('DC', 'Dyscalculie'), ('DP', 'Dyspraxie'), ('DG', 'Dysgraphie'), ('DO', 'Dysorthographie')], max_length=14, null=True, verbose_name='Troubles cognitifs'),
),
migrations.AddField(
model_name='baseeleve',
name='ville_natale',
field=models.CharField(blank=True, max_length=50, null=True, verbose_name='Ville natale'),
),
migrations.AlterField(
model_name='baseeleve',
name='commune_naissance',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='inscription.commune', verbose_name='Commune de naissance'),
),
migrations.AlterField(
model_name='baseeleve',
name='departement_naissance',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='inscription.departement', verbose_name='Département de naissance'),
),
]

0 comments on commit d966afe

Please sign in to comment.