from typing import Optional

from pydantic import BaseModel

from src.model.view.user_view_model import UserViewModel
from src.system_var import constants


class MenuViewModel(BaseModel):
    subtitle: str = 'MeDaCA 機能メニュー'
    batch_status: Optional[str]
    dump_status: Optional[str]
    user_model: UserViewModel

    def is_batch_processing(self):
        return self.batch_status == constants.BATCH_STATUS_PROCESSING

    def is_backup_processing(self):
        return self.dump_status != constants.DUMP_STATUS_UNPROCESSED

    def is_available_ult_doctor_menu(self):
        return self.user_model.has_ult_doctor_permission()

    def is_available_ult_inst_menu(self):
        return self.user_model.has_ult_inst_permission()

    def is_available_bio_menu(self):
        return self.user_model.has_bio_permission()

    def is_available_master_maintenance_menu(self):
        return self.user_model.has_master_maintenance_permission()
