From 0c4032db9a32d8e57f9cac0738d04a06dff11f27 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Wed, 24 Jul 2019 23:21:48 +0200 Subject: [PATCH] Declare fields unique. --- biscuit/apps/chronos/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py index b1182497..094d7fe3 100644 --- a/biscuit/apps/chronos/models.py +++ b/biscuit/apps/chronos/models.py @@ -18,6 +18,7 @@ class TimePeriod(models.Model): 'Week day'), choices=WEEKDAY_CHOICES) period = models.PositiveSmallIntegerField( verbose_name=_('Number of period')) + time_start = models.TimeField(verbose_name=_('Time the period starts')) time_end = models.TimeField(verbose_name=_('Time the period ends')) @@ -32,12 +33,15 @@ class TimePeriod(models.Model): return periods + class Meta: + unique_together = [['weekday', 'period']] + class Subject(models.Model): abbrev = models.CharField(verbose_name=_( - 'Abbreviation of subject in timetable'), max_length=10) + 'Abbreviation of subject in timetable'), max_length=10, unique=True) name = models.CharField(verbose_name=_( - 'Long name of subject'), max_length=30) + 'Long name of subject'), max_length=30, unique=True) colour_fg = models.CharField(verbose_name=_('Foreground colour in timetable'), blank=True, validators=[ validators.RegexValidator(r'#[0-9A-F]{6}')], max_length=7) -- GitLab