import json

from django.contrib.contenttypes.fields import GenericRelation
from django.db import models

class TtStaff(models.Model):

    code = models.CharField(max_length=150)
    name = models.CharField(max_length=255)
    email = models.EmailField(null=True)
    desc = models.TextField(null=True)
    department = models.ForeignKey("api.TtDepartment", on_delete=models.SET_NULL,null=True)
    is_part_time = models.BooleanField(default=False)
    maximum_period = models.IntegerField(null=True)
    contract_period = models.IntegerField(null=True)
    shared_with_all_department = models.BooleanField(default=False)
    status = models.SmallIntegerField()
    created_by = models.BigIntegerField(null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_by = models.BigIntegerField(null=True)
    updated_at = models.DateTimeField(auto_now=True)

    shared_with_department = models.ManyToManyField("api.TtDepartment",through="api.TtStaffSharedWithDepartment",related_name="staff_shared_with_department")

    STATUS_TO_CODE = {
        "active": 1,
        "inactive": 2,
    }

    IMPORT_RULES = {
        
    }

    class Meta:
        db_table = "tt_staff"

    def __str__(self):
        return self.name
    
