Allow multiple fields for supplies

This commit is contained in:
Gabriel Augendre 2018-05-24 00:36:17 +02:00
parent 70fa58fd46
commit 20ef3ce11d
4 changed files with 40 additions and 3 deletions

View file

@ -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']

View file

@ -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',
),
]

View file

@ -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'),
),
]

View file

@ -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):