diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4fe7c5c087a6906420ef8e212266571a3abc6984..4de936f758f38e8dca36db3faffd78dcafcf52c4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Changelog ========= +Unreleased +---------- + +Fixed +~~~~~ + +* Unique constraints for breaks and substitutions were too tight + `2.0b0`_ - 2021-05-21 --------------------- diff --git a/aleksis/apps/chronos/migrations/0007_unique_constraints.py b/aleksis/apps/chronos/migrations/0007_unique_constraints.py index 754c3ae1c1c9c7a8a4e3ab6f616a459cf65d5298..048da7fde020013012c04922859e89f5b9e5ddfc 100644 --- a/aleksis/apps/chronos/migrations/0007_unique_constraints.py +++ b/aleksis/apps/chronos/migrations/0007_unique_constraints.py @@ -52,11 +52,11 @@ class Migration(migrations.Migration): ), migrations.AddConstraint( model_name='break', - constraint=models.UniqueConstraint(fields=('site_id', 'short_name'), name='unique_short_name_per_site_break'), + constraint=models.UniqueConstraint(fields=('validity', 'short_name'), name='unique_short_name_per_site_break'), ), migrations.AddConstraint( model_name='lessonsubstitution', - constraint=models.UniqueConstraint(fields=('lesson_period', 'week'), name='unique_period_per_week'), + constraint=models.UniqueConstraint(fields=('lesson_period', 'week', 'year'), name='unique_period_per_week'), ), migrations.AddConstraint( model_name='room', diff --git a/aleksis/apps/chronos/models.py b/aleksis/apps/chronos/models.py index 97f701ee1c3bc2fd591a7572dff96e3844c03654..07dc3fda0bd8429f7c335093bbe0b2ae3a07b723 100644 --- a/aleksis/apps/chronos/models.py +++ b/aleksis/apps/chronos/models.py @@ -451,7 +451,7 @@ class LessonSubstitution(ExtensibleModel, TeacherPropertiesMixin, WeekRelatedMix ), # Heads up: Link to period implies uniqueness per site models.UniqueConstraint( - fields=["lesson_period", "week"], name="unique_period_per_week" + fields=["lesson_period", "week", "year"], name="unique_period_per_week" ), ] indexes = [ @@ -866,7 +866,7 @@ class Break(ValidityRangeRelatedExtensibleModel): verbose_name_plural = _("Breaks") constraints = [ models.UniqueConstraint( - fields=["site_id", "short_name"], name="unique_short_name_per_site_break" + fields=["validity", "short_name"], name="unique_short_name_per_site_break" ), ]