Added instructor availability model and admin
This commit is contained in:
79
cntmanage/flightslot/models/availabilities.py
Normal file
79
cntmanage/flightslot/models/availabilities.py
Normal 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]}."
|
||||
|
||||
Reference in New Issue
Block a user