From 900bc53ab8bd75a76d439231c1c07006f8a1b169 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 6 Apr 2019 19:26:06 +0200 Subject: [PATCH] Allow only one discipline per supplies requirement --- manuels/forms.py | 5 ++--- manuels/migrations/0031_auto_20190406_1912.py | 18 ++++++++++++++++++ manuels/migrations/0032_auto_20190406_1913.py | 18 ++++++++++++++++++ manuels/models.py | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 manuels/migrations/0031_auto_20190406_1912.py create mode 100644 manuels/migrations/0032_auto_20190406_1913.py diff --git a/manuels/forms.py b/manuels/forms.py index f2e417e..1a9e84b 100644 --- a/manuels/forms.py +++ b/manuels/forms.py @@ -70,11 +70,10 @@ class AddBookForm(EditBookForm): class EditSuppliesForm(forms.ModelForm): class Meta: model = SuppliesRequirement - fields = ['teacher', 'level', 'fields', 'supplies'] + fields = ['teacher', 'level', 'field', 'supplies'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['fields'].widget.attrs.update(rows=3) self.fields['supplies'].widget.attrs.update(rows=3) self.fields['teacher'].widget.attrs.update({'class': 'custom-select'}) if 'level' in self.fields: @@ -83,7 +82,7 @@ class EditSuppliesForm(forms.ModelForm): class AddSuppliesForm(EditSuppliesForm): 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) levels = forms.ModelMultipleChoiceField( diff --git a/manuels/migrations/0031_auto_20190406_1912.py b/manuels/migrations/0031_auto_20190406_1912.py new file mode 100644 index 0000000..482c44d --- /dev/null +++ b/manuels/migrations/0031_auto_20190406_1912.py @@ -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'), + ), + ] diff --git a/manuels/migrations/0032_auto_20190406_1913.py b/manuels/migrations/0032_auto_20190406_1913.py new file mode 100644 index 0000000..5d283a3 --- /dev/null +++ b/manuels/migrations/0032_auto_20190406_1913.py @@ -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'), + ), + ] diff --git a/manuels/models.py b/manuels/models.py index d8a6644..fd53773 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -223,7 +223,7 @@ class SuppliesRequirement(BaseModel): 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) - fields = models.TextField('disciplines') + field = models.CharField('discipline', max_length=50) supplies = models.TextField('fournitures') done = models.BooleanField( 'Traité',