From 67f33093826de59ff7e3fc71e446726c5100a294 Mon Sep 17 00:00:00 2001 From: Tom Teichler <tom.teichler@teckids.org> Date: Sat, 7 Sep 2019 17:34:30 +0200 Subject: [PATCH] Make fields not required. Neccessary for lesson cacellation. Closes #30. --- biscuit/apps/chronos/migrations/0001_initial.py | 6 +++--- biscuit/apps/chronos/models.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/biscuit/apps/chronos/migrations/0001_initial.py b/biscuit/apps/chronos/migrations/0001_initial.py index ee4f83f6..6fdf91d7 100644 --- a/biscuit/apps/chronos/migrations/0001_initial.py +++ b/biscuit/apps/chronos/migrations/0001_initial.py @@ -87,10 +87,10 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('week', models.IntegerField(default=biscuit.apps.chronos.util.current_week, verbose_name='Week')), ('lesson_period', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='substitutions', to='chronos.LessonPeriod')), - ('room', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='chronos.Room')), + ('room', models.ForeignKey(null=True, blank=True, on_delete=django.db.models.deletion.CASCADE, to='chronos.Room')), ('school', models.ForeignKey(default=biscuit.core.util.core_helpers.get_current_school, on_delete=django.db.models.deletion.CASCADE, to='core.School')), - ('subject', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='lesson_substitutions', to='chronos.Subject')), - ('teachers', models.ManyToManyField(related_name='lesson_substitutions', to='core.Person')), + ('subject', models.ForeignKey(null=True, blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='lesson_substitutions', to='chronos.Subject')), + ('teachers', models.ManyToManyField(null=True, blank=True, related_name='lesson_substitutions', to='core.Person')), ], options={ 'ordering': ['lesson_period__lesson__date_start', 'week', 'lesson_period__period__weekday', 'lesson_period__period__period'], diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py index 9a5d5290..744ba215 100644 --- a/biscuit/apps/chronos/models.py +++ b/biscuit/apps/chronos/models.py @@ -116,10 +116,10 @@ class LessonSubstitution(SchoolRelated): subject = models.ForeignKey( 'Subject', on_delete=models.CASCADE, - related_name='lesson_substitutions', null=True) + related_name='lesson_substitutions', null=True, blank=True) teachers = models.ManyToManyField('core.Person', - related_name='lesson_substitutions') - room = models.ForeignKey('Room', models.CASCADE, null=True) + related_name='lesson_substitutions', blank=True, null=True) + room = models.ForeignKey('Room', models.CASCADE, null=True, blank=True) cancelled = models.BooleanField(default=False) -- GitLab