2020-11-22 22:08:09 +01:00
|
|
|
from django.db import models
|
2020-12-20 23:10:49 +01:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
ACTIVITY_TYPES = [('work', 'Work'),
|
|
|
|
('vacation', 'Vacation'),
|
|
|
|
('sickness', 'Sickness'),
|
|
|
|
('parental_leave', 'Parental leave'),
|
|
|
|
]
|
|
|
|
|
2020-11-22 22:08:09 +01:00
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
class Employee(models.Model):
|
2020-12-20 23:10:49 +01:00
|
|
|
username = models.OneToOneField(User, on_delete=models.CASCADE,
|
|
|
|
to_field='username',
|
|
|
|
db_column="username",
|
|
|
|
primary_key=True)
|
2020-11-22 22:08:09 +01:00
|
|
|
department = models.CharField(max_length=200,
|
|
|
|
null=False,
|
|
|
|
blank=False)
|
2020-12-20 23:10:49 +01:00
|
|
|
manager_username = models.CharField(max_length=200)
|
|
|
|
time_model = models.ForeignKey('TimeModel', on_delete=models.PROTECT)
|
|
|
|
manager_flag = models.BooleanField()
|
|
|
|
|
|
|
|
|
|
|
|
class TimeModel(models.Model):
|
|
|
|
time_model_id = models.IntegerField(primary_key=True)
|
|
|
|
daily_hours = models.DecimalField(max_digits=4, decimal_places=2)
|
|
|
|
weekly_days = models.IntegerField()
|
|
|
|
mon = models.BooleanField()
|
|
|
|
tue = models.BooleanField()
|
|
|
|
wed = models.BooleanField()
|
|
|
|
thu = models.BooleanField()
|
|
|
|
fri = models.BooleanField()
|
|
|
|
sat = models.BooleanField()
|
|
|
|
sun = models.BooleanField()
|
|
|
|
|
|
|
|
class Plan(models.Model):
|
|
|
|
username = models.ForeignKey(Employee, on_delete=models.PROTECT)
|
|
|
|
date = models.DateField()
|
|
|
|
begin_time = models.TimeField()
|
|
|
|
end_time = models.TimeField()
|
|
|
|
activity_type = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
|
|
|
|
class TimeLog(models.Model):
|
|
|
|
username = models.ForeignKey(Employee, on_delete=models.PROTECT)
|
|
|
|
date = models.DateField()
|
|
|
|
begin_time = models.TimeField()
|
2021-01-05 23:18:41 +01:00
|
|
|
end_time = models.TimeField(null=True)
|
2020-12-20 23:10:49 +01:00
|
|
|
activity_type = models.CharField(max_length=100)
|
2020-12-28 19:40:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PlanCreationLog(models.Model):
|
|
|
|
username = models.ForeignKey(Employee, on_delete=models.PROTECT)
|
|
|
|
report_location = models.CharField(max_length=500)
|
|
|
|
creation_date = models.DateTimeField(auto_now_add=True)
|