56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
ACTIVITY_TYPES = [('work', 'Work'),
|
|
('vacation', 'Vacation'),
|
|
('sickness', 'Sickness'),
|
|
('parental_leave', 'Parental leave'),
|
|
]
|
|
|
|
|
|
# Create your models here.
|
|
class Employee(models.Model):
|
|
username = models.OneToOneField(User, on_delete=models.CASCADE,
|
|
to_field='username',
|
|
db_column="username",
|
|
primary_key=True)
|
|
department = models.CharField(max_length=200,
|
|
null=False,
|
|
blank=False)
|
|
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()
|
|
end_time = models.TimeField(null=True)
|
|
activity_type = models.CharField(max_length=100)
|
|
|
|
|
|
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) |