57 lines
1 KiB
Python
57 lines
1 KiB
Python
import tomllib
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from .settings import SETTINGS
|
|
from .webdav import WebDAV
|
|
|
|
|
|
class User(BaseModel):
|
|
name: str
|
|
password: str
|
|
|
|
|
|
class Server(BaseModel):
|
|
# Dateiname Schriftart
|
|
font: str
|
|
|
|
# Tag, an dem der Kalender startet
|
|
# TODO penner
|
|
begin_day: int = 1
|
|
|
|
# Monat, in dem der Kalender startet
|
|
# TODO penner
|
|
begin_month: int = 12
|
|
|
|
# Kalender so viele Tage nach der letzten Türöffnung schließen
|
|
# TODO penner
|
|
close_after: int = 90
|
|
|
|
|
|
class Puzzle(BaseModel):
|
|
# Titel
|
|
title: str
|
|
|
|
# Lösungswort
|
|
solution: str
|
|
|
|
# Kalenderdefinition
|
|
calendar: str = "default.toml"
|
|
|
|
# Serverseitiger zusätzlicher "random" seed
|
|
random_seed: str = ""
|
|
|
|
|
|
class Config(BaseModel):
|
|
admin: User
|
|
server: Server
|
|
puzzle: Puzzle
|
|
|
|
|
|
async def get_config() -> Config:
|
|
"""
|
|
Globale Konfiguration lesen
|
|
"""
|
|
|
|
txt = await WebDAV.read_str(path=SETTINGS.webdav.config_filename)
|
|
return Config.model_validate(tomllib.loads(txt))
|