Added instructor availability model and admin

This commit is contained in:
2025-12-02 12:00:15 +01:00
parent 5d1686f24b
commit 3ee2269d70
10 changed files with 236 additions and 9 deletions

View File

@@ -0,0 +1,79 @@
from django.db import models
from datetime import date
from ..models.instructors import Instructor
class Availability(models.Model):
id = models.BigAutoField(
primary_key=True
)
week = models.PositiveSmallIntegerField(
null=False,
db_index=True,
db_default=date.today().isocalendar().week,
auto_created=True,
verbose_name="Week Number"
)
instructor = models.ForeignKey(
Instructor,
null=False,
db_index=True,
on_delete=models.CASCADE,
verbose_name="Instructor Selection"
)
monday = models.BooleanField(
default=True,
null=False
)
tuesday = models.BooleanField(
default=True,
null=False
)
wednesday = models.BooleanField(
default=True,
null=False
)
thursday = models.BooleanField(
default=True,
null=False
)
friday = models.BooleanField(
default=True,
null=False
)
saturday = models.BooleanField(
default=True,
null=False
)
sunday = models.BooleanField(
default=True,
null=False
)
hours = models.DurationField(
null=True,
verbose_name="Available hours"
)
notes = models.TextField(
max_length=140,
null=True,
blank=True
)
class Meta():
verbose_name = "Instructor Availability"
verbose_name_plural = "Instructor Availabilities"
def __str__(self):
return f"Week {self.week} - {self.instructor.surname} {self.instructor.name[0]}."