From 20ef3ce11df168741fd840dd17096b37ceefb6f9 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 24 May 2018 00:36:17 +0200 Subject: [PATCH] Allow multiple fields for supplies --- manuels/admin.py | 5 +++-- manuels/migrations/0014_auto_20180524_0034.py | 18 ++++++++++++++++++ manuels/migrations/0015_auto_20180524_0035.py | 18 ++++++++++++++++++ manuels/models.py | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 manuels/migrations/0014_auto_20180524_0034.py create mode 100644 manuels/migrations/0015_auto_20180524_0035.py diff --git a/manuels/admin.py b/manuels/admin.py index fd8c262..2f9e69b 100644 --- a/manuels/admin.py +++ b/manuels/admin.py @@ -68,12 +68,13 @@ class EditorAdmin(admin.ModelAdmin): class SuppliesResource(resources.ModelResource): class Meta: model = SuppliesRequirement - fields = ('supplies', 'level__name', 'teacher__first_name', 'teacher__last_name') + fields = ('supplies', 'fields', 'level__name', 'teacher__first_name', 'teacher__last_name') + export_order = ('fields', 'supplies', 'teacher__first_name', 'teacher__last_name', 'level__name') @admin.register(SuppliesRequirement) class SuppliesRequirementAdmin(ExportMixin, admin.ModelAdmin): resource_class = SuppliesResource - list_display = ['teacher', 'level', 'supplies'] + list_display = ['id', 'teacher', 'level', 'fields', 'supplies'] readonly_fields = ['created_at', 'updated_at'] list_filter = ['teacher', 'level'] diff --git a/manuels/migrations/0014_auto_20180524_0034.py b/manuels/migrations/0014_auto_20180524_0034.py new file mode 100644 index 0000000..5b595d4 --- /dev/null +++ b/manuels/migrations/0014_auto_20180524_0034.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.5 on 2018-05-23 22:34 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('manuels', '0013_auto_20180524_0016'), + ] + + operations = [ + migrations.RenameField( + model_name='suppliesrequirement', + old_name='field', + new_name='fields', + ), + ] diff --git a/manuels/migrations/0015_auto_20180524_0035.py b/manuels/migrations/0015_auto_20180524_0035.py new file mode 100644 index 0000000..b34b0c5 --- /dev/null +++ b/manuels/migrations/0015_auto_20180524_0035.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.5 on 2018-05-23 22:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('manuels', '0014_auto_20180524_0034'), + ] + + operations = [ + migrations.AlterField( + model_name='suppliesrequirement', + name='fields', + field=models.TextField(verbose_name='matières'), + ), + ] diff --git a/manuels/models.py b/manuels/models.py index a557996..a4c8663 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -151,7 +151,7 @@ class SuppliesRequirement(BaseModel): teacher = models.ForeignKey(verbose_name='enseignant', to=Teacher, on_delete=models.PROTECT, null=True) level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True) - field = models.CharField('matière', max_length=200) + fields = models.TextField('matières') supplies = models.TextField('fournitures') def __str__(self):