import json

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

class TtStudent(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)
    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)

    academic_term = models.ManyToManyField("api.TtAcademicTerm",through="api.TtStudentAcademicTerm")
    pos = models.ManyToManyField("api.TtPos",through="api.TtStudentPos")
    pos_module = models.ManyToManyField("api.TtPosModuleGroupModule",through="api.TtStudentPosModule")

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

    IMPORT_RULES = {

    }

    class Meta:
        db_table = "tt_student"

    def __str__(self):
        return self.name