Files
Flagman/instructor/models.py
Dmitriy 60b4e0e839 init
2025-06-23 01:24:34 +03:00

36 lines
1.4 KiB
Python

from django.db import models
from django.contrib.auth.models import User
from accounts.models import Profile
class Instructor(models.Model):
profile = models.OneToOneField(Profile, on_delete=models.CASCADE)
experience_years = models.IntegerField(default=0)
specialization = models.CharField(max_length=100)
rating = models.DecimalField(max_digits=3, decimal_places=2, default=5.00)
is_available = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"{self.profile.user.get_full_name()} - {self.specialization}"
class InstructorSchedule(models.Model):
instructor = models.ForeignKey(Instructor, on_delete=models.CASCADE)
day_of_week = models.IntegerField(choices=[
(0, 'Понедельник'),
(1, 'Вторник'),
(2, 'Среда'),
(3, 'Четверг'),
(4, 'Пятница'),
(5, 'Суббота'),
(6, 'Воскресенье'),
])
start_time = models.TimeField()
end_time = models.TimeField()
is_available = models.BooleanField(default=True)
class Meta:
unique_together = ('instructor', 'day_of_week')
def __str__(self):
return f"{self.instructor} - {self.get_day_of_week_display()} ({self.start_time}-{self.end_time})"