bug: calendar config filename

This commit is contained in:
Jörn-Michael Miehe 2023-09-08 19:59:26 +00:00
parent 14896960c2
commit e51744ddc9
2 changed files with 6 additions and 5 deletions

View file

@ -4,9 +4,8 @@ from typing import TypeAlias
import tomli_w
from pydantic import BaseModel
from .config import get_config
from .config import Config, get_config
from .dav_common import dav_get_textfile_content, dav_write_textfile_content
from .settings import SETTINGS
class DoorSaved(BaseModel):
@ -41,9 +40,9 @@ async def get_calendar_config() -> CalendarConfig:
return CalendarConfig.model_validate(tomllib.loads(txt))
async def set_calendar_config(cal_cfg: CalendarConfig) -> None:
async def set_calendar_config(cfg: Config, cal_cfg: CalendarConfig) -> None:
await dav_write_textfile_content(
path=SETTINGS.config_filename,
path=f"files/{cfg.puzzle.calendar}",
content=tomli_w.dumps(
cal_cfg.model_dump(
exclude_defaults=True,

View file

@ -8,6 +8,7 @@ from ..calendar_config import (
get_calendar_config,
set_calendar_config,
)
from ..config import Config, get_config
from ..dav_common import dav_get_file
from ._misc import api_return_image
@ -44,6 +45,7 @@ async def get_doors(
@router.put("/doors")
async def put_doors(
doors: DoorsSaved,
cfg: Config = Depends(get_config),
cal_cfg: CalendarConfig = Depends(get_calendar_config),
) -> None:
"""
@ -54,4 +56,4 @@ async def put_doors(
doors,
key=lambda door: door.day,
)
await set_calendar_config(cal_cfg)
await set_calendar_config(cfg, cal_cfg)