Allow only one discipline per supplies requirement
This commit is contained in:
parent
62269ec957
commit
900bc53ab8
4 changed files with 39 additions and 4 deletions
|
@ -70,11 +70,10 @@ class AddBookForm(EditBookForm):
|
||||||
class EditSuppliesForm(forms.ModelForm):
|
class EditSuppliesForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SuppliesRequirement
|
model = SuppliesRequirement
|
||||||
fields = ['teacher', 'level', 'fields', 'supplies']
|
fields = ['teacher', 'level', 'field', 'supplies']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['fields'].widget.attrs.update(rows=3)
|
|
||||||
self.fields['supplies'].widget.attrs.update(rows=3)
|
self.fields['supplies'].widget.attrs.update(rows=3)
|
||||||
self.fields['teacher'].widget.attrs.update({'class': 'custom-select'})
|
self.fields['teacher'].widget.attrs.update({'class': 'custom-select'})
|
||||||
if 'level' in self.fields:
|
if 'level' in self.fields:
|
||||||
|
@ -83,7 +82,7 @@ class EditSuppliesForm(forms.ModelForm):
|
||||||
|
|
||||||
class AddSuppliesForm(EditSuppliesForm):
|
class AddSuppliesForm(EditSuppliesForm):
|
||||||
class Meta(EditSuppliesForm.Meta):
|
class Meta(EditSuppliesForm.Meta):
|
||||||
fields = ['teacher', 'levels', 'fields', 'supplies']
|
fields = ['teacher', 'levels', 'field', 'supplies']
|
||||||
|
|
||||||
add_another = forms.BooleanField(label="Ajouter d'autres fournitures", required=False, initial=True)
|
add_another = forms.BooleanField(label="Ajouter d'autres fournitures", required=False, initial=True)
|
||||||
levels = forms.ModelMultipleChoiceField(
|
levels = forms.ModelMultipleChoiceField(
|
||||||
|
|
18
manuels/migrations/0031_auto_20190406_1912.py
Normal file
18
manuels/migrations/0031_auto_20190406_1912.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2 on 2019-04-06 17:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('manuels', '0030_auto_20190406_1912'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='suppliesrequirement',
|
||||||
|
name='field',
|
||||||
|
field=models.CharField(max_length=50, verbose_name='disciplines'),
|
||||||
|
),
|
||||||
|
]
|
18
manuels/migrations/0032_auto_20190406_1913.py
Normal file
18
manuels/migrations/0032_auto_20190406_1913.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2 on 2019-04-06 17:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('manuels', '0031_auto_20190406_1912'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='suppliesrequirement',
|
||||||
|
name='field',
|
||||||
|
field=models.CharField(max_length=50, verbose_name='discipline'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -223,7 +223,7 @@ class SuppliesRequirement(BaseModel):
|
||||||
|
|
||||||
teacher = models.ForeignKey(verbose_name='coordonnateur', to=Teacher, on_delete=models.PROTECT, null=True)
|
teacher = models.ForeignKey(verbose_name='coordonnateur', to=Teacher, on_delete=models.PROTECT, null=True)
|
||||||
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True)
|
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True)
|
||||||
fields = models.TextField('disciplines')
|
field = models.CharField('discipline', max_length=50)
|
||||||
supplies = models.TextField('fournitures')
|
supplies = models.TextField('fournitures')
|
||||||
done = models.BooleanField(
|
done = models.BooleanField(
|
||||||
'Traité',
|
'Traité',
|
||||||
|
|
Loading…
Reference in a new issue