class Shelude(models.Model):
days = (
(1, 'Понедельник'),
(2, 'Вторник'),
(3, 'Среда'),
(4, 'Четверг'),
(5, 'Пятница'),
)
orders = (
(1, 'Первая'),
(2, 'Вторая'),
(3, 'Третья'),
(4, 'Четвертая'),
(5, 'Пятая'),
(6, 'Шестая'),
(7, 'Седьмая'),
(8, 'Восьмая'),
)
week_type = (
(0, 'Общая'),
(1, 'Нечетная'),
(1, 'четная')
)
day = models.PositiveSmallIntegerField(choices=days, verbose_name='День недели')
order = models.PositiveSmallIntegerField(choices=orders, verbose_name='Номер пары')
room = models.CharField(verbose_name='Номер аудитории', max_length=5)
building = models.CharField(verbose_name='Корпус', max_length=5)
is_even = models.PositiveSmallIntegerField(verbose_name='Четная', choices=week_type, default=0)
group = models.ForeignKey(StudyGroup, on_delete=models.CASCADE, verbose_name='Учебная группа')
lector = models.ForeignKey(Lector, on_delete=models.CASCADE, verbose_name='Преподаватель')
discipline = models.ForeignKey(Discipline, on_delete=models.CASCADE, verbose_name='Дисциплина')
def __str__(self):
return f'{self.group} - {self.order}.{self.discipline} ({self.get_day_display()})'
class Meta:
unique_together = ['group', 'day', 'order', 'is_even']
ordering = ['group', 'day', 'order']
verbose_name = 'Расписание'
verbose_name_plural = 'Расписания'