from typing import Optional

from pydantic import BaseModel

from src.system_var import constants


class UserViewModel(BaseModel):
    bio_flg: Optional[int]  # AUTH_FLG1
    doc_flg: Optional[int]  # AUTH_FLG2
    inst_flg: Optional[int]  # AUTH_FLG3
    master_mainte_flg: Optional[int]  # AUTH_FLG4

    def has_ult_doctor_permission(self):
        return self.doc_flg == constants.PERMISSION_ENABLED

    def has_ult_inst_permission(self):
        return self.inst_flg == constants.PERMISSION_ENABLED

    def has_bio_permission(self):
        return self.bio_flg == constants.PERMISSION_ENABLED

    def has_master_maintenance_permission(self):
        return self.master_mainte_flg == constants.PERMISSION_ENABLED
