start building rota functions into site
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
from django.contrib.postgres.fields import DateRangeField
|
||||
from django.conf import settings
|
||||
|
||||
from generic.models import Site
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
|
||||
class OutOfProgrameEvent(models.Model):
|
||||
date_range = DateRangeField(help_text="The range of the out of programe event")
|
||||
end_date = models.DateField()
|
||||
reason = models.CharField(max_length=255)
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
|
||||
class LeaveRequest(models.Model):
|
||||
date_range = DateRangeField(help_text="The range of the leave request")
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
|
||||
LEAVE_STATUS = (
|
||||
("UNDECIDED", "Undecided"),
|
||||
("REJECTED", "Rejected" ),
|
||||
("ACCEPTED", "Accepted" )
|
||||
)
|
||||
|
||||
status = models.CharField(max_length=10, choices=LEAVE_STATUS, default="UNDECIDED")
|
||||
|
||||
reason = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.date_range} / {self.reason} / {self.status}"
|
||||
|
||||
class MultiLeaveRequest(models.Model):
|
||||
date_range = DateRangeField(help_text="The range of the leave request")
|
||||
|
||||
users = models.ManyToManyField(settings.AUTH_USER_MODEL)
|
||||
|
||||
reason = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.date_range} / {self.reason}"
|
||||
|
||||
class RotaRotation(models.Model):
|
||||
name = models.CharField(max_length=100, help_text="Name of the rotation")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Rota(models.Model):
|
||||
start_date = models.DateField(help_text="The rota start date")
|
||||
weeks_to_rota = models.IntegerField(default=26, help_text="The number of (whole) weeks the rota cycle runs for")
|
||||
|
||||
rotations = models.ManyToManyField(RotaRotation, help_text="The rotations that are in the rota")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.start_date} : {self.weeks_to_rota} weeks"
|
||||
|
||||
|
||||
class UserRotaDetail(models.Model):
|
||||
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
|
||||
rotation = models.ForeignKey(RotaRotation, on_delete=models.SET_NULL, null=True)
|
||||
|
||||
proc_site = models.ForeignKey(Site, on_delete=models.SET_NULL, null=True)
|
||||
|
||||
end_date = models.DateField(blank=True, null=True, help_text="The date the user should be roted up until, for example their CCT date")
|
||||
start_date = models.DateField(blank=True, null=True, help_text="The date the user should be roted from, for example if they join part way through a rota cycle")
|
||||
|
||||
full_time_equivalence = models.IntegerField(default=100, validators=[MaxValueValidator(100), MinValueValidator(0)], help_text="Percentage of FTE, 100 = Full Time")
|
||||
|
||||
nwd_monday = models.BooleanField(default=False)
|
||||
nwd_tuesday = models.BooleanField(default=False)
|
||||
nwd_wednesday = models.BooleanField(default=False)
|
||||
nwd_thursday = models.BooleanField(default=False)
|
||||
nwd_friday = models.BooleanField(default=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user