""" This module contains the configuration for the 'base' app. """ from django.apps import AppConfig, apps from horilla.horilla_settings import NO_PERMISSION_MODALS class BaseConfig(AppConfig): """ Configuration class for the 'base' app. """ default_auto_field = "django.db.models.BigAutoField" name = "base" def ready(self) -> None: from base import signals super().ready() check_for_no_permissions_models() try: from base.models import EmployeeShiftDay if not EmployeeShiftDay.objects.exists(): days = [ ("monday", "Monday"), ("tuesday", "Tuesday"), ("wednesday", "Wednesday"), ("thursday", "Thursday"), ("friday", "Friday"), ("saturday", "Saturday"), ("sunday", "Sunday"), ] EmployeeShiftDay.objects.bulk_create( [EmployeeShiftDay(day=day[0]) for day in days] ) except Exception as e: print(e) def check_for_no_permissions_models(): model_names = set() for model in apps.get_models(): if getattr(model, "_no_permission_model", False): model_names.add(model._meta.model_name) NO_PERMISSION_MODALS.extend(list(model_names))