diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 062f03e131c41b5c0d2724a21da349f9be449e11..eed15b70b9b58414166bc21b9d35c8029cbab37b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Changelog ========= +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 ---------- @@ -8,6 +13,7 @@ Fixed ~~~~~ * Migration path was ambigious +* Unique constraints for breaks and substitutions were too tight `2.0b0`_ - 2021-05-21 --------------------- diff --git a/aleksis/apps/chronos/migrations/0008_unique_constraints.py b/aleksis/apps/chronos/migrations/0008_unique_constraints.py index 03f9a2cb8d16fb2e5d788cffb78df016fc8873a6..df88345e151019bdc5830323aefb13c2e8cf2716 100644 --- a/aleksis/apps/chronos/migrations/0008_unique_constraints.py +++ b/aleksis/apps/chronos/migrations/0008_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" ), ]