ovdashboard/api/ovkiosk/config.py

47 lines
1.1 KiB
Python

"""
Configuration definition.
Converts per-run (environment) variables and config files into the
"python world" using `pydantic`.
Pydantic models might have convenience methods attached.
"""
from typing import Optional
from pydantic import BaseSettings
class Settings(BaseSettings):
"""
Per-run settings
"""
production_mode: bool = False
api_v1_prefix: str = "api/v1"
openapi_url: str = "/openapi.json"
docs_url: Optional[str] = "/docs"
redoc_url: Optional[str] = "/redoc"
caldav_base_url: str = "/remote.php/dav"
webdav_base_url: str = "/remote.php/webdav/ovkiosk"
dav_protocol: str = "https"
dav_host: str = "example.com"
dav_username: str = "ovkiosk"
dav_password: str = "changeme"
dav_path: str = "ovkiosk"
ticker_separator: str = " +++ "
@property
def caldav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.caldav_base_url}"
@property
def webdav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.webdav_base_url}"
SETTINGS = Settings(_env_file=".env")