75 lines
1.3 KiB
Python
75 lines
1.3 KiB
Python
import tomllib
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from .settings import SETTINGS
|
|
from .webdav import WebDAV
|
|
|
|
|
|
class User(BaseModel):
|
|
name: str
|
|
password: str
|
|
|
|
|
|
class Puzzle(BaseModel):
|
|
# Titel
|
|
# TODO neue Route GET /user/title
|
|
title: str
|
|
|
|
# Lösungswort
|
|
solution: 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 TTFont(BaseModel):
|
|
# Dateiname (in "/files")
|
|
file: str
|
|
|
|
# Schriftgröße für den Font
|
|
size: int = 50
|
|
|
|
|
|
class Image(BaseModel):
|
|
# Quadrat, Seitenlänge in px
|
|
# TODO penner
|
|
size: int = 1000
|
|
|
|
# Rand in px, wo keine Buchstaben untergebracht werden
|
|
# TODO penner
|
|
border: int = 60
|
|
|
|
# Schriftarten
|
|
# TODO
|
|
fonts: list[TTFont]
|
|
|
|
|
|
class Config(BaseModel):
|
|
admin: User
|
|
puzzle: Puzzle
|
|
image: Image
|
|
|
|
# Kalenderdefinition
|
|
calendar: str = "default.toml"
|
|
|
|
# Serverseitiger zusätzlicher "random" seed
|
|
random_seed: str = ""
|
|
|
|
|
|
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))
|