diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 428c3f4ae8b7226f9d0c53c4e655c27cf3ce126a..9995909669cc0cabab92d79bc06f88dde862efca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog`_, and this project adheres to `Semantic Versioning`_. +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" ), ]