from __future__ import annotations

from sqlalchemy.orm import Session

from govoplan_core.admin.models import SystemSettings

SYSTEM_SETTINGS_ID = "global"


def get_system_settings(session: Session) -> SystemSettings:
    item = session.get(SystemSettings, SYSTEM_SETTINGS_ID)
    if item is None:
        item = SystemSettings(id=SYSTEM_SETTINGS_ID)
        session.add(item)
        session.flush()
    return item
