bug: calendar config filename
This commit is contained in:
parent
14896960c2
commit
e51744ddc9
2 changed files with 6 additions and 5 deletions
|
@ -4,9 +4,8 @@ from typing import TypeAlias
|
||||||
import tomli_w
|
import tomli_w
|
||||||
from pydantic import BaseModel
|
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 .dav_common import dav_get_textfile_content, dav_write_textfile_content
|
||||||
from .settings import SETTINGS
|
|
||||||
|
|
||||||
|
|
||||||
class DoorSaved(BaseModel):
|
class DoorSaved(BaseModel):
|
||||||
|
@ -41,9 +40,9 @@ async def get_calendar_config() -> CalendarConfig:
|
||||||
return CalendarConfig.model_validate(tomllib.loads(txt))
|
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(
|
await dav_write_textfile_content(
|
||||||
path=SETTINGS.config_filename,
|
path=f"files/{cfg.puzzle.calendar}",
|
||||||
content=tomli_w.dumps(
|
content=tomli_w.dumps(
|
||||||
cal_cfg.model_dump(
|
cal_cfg.model_dump(
|
||||||
exclude_defaults=True,
|
exclude_defaults=True,
|
||||||
|
|
|
@ -8,6 +8,7 @@ from ..calendar_config import (
|
||||||
get_calendar_config,
|
get_calendar_config,
|
||||||
set_calendar_config,
|
set_calendar_config,
|
||||||
)
|
)
|
||||||
|
from ..config import Config, get_config
|
||||||
from ..dav_common import dav_get_file
|
from ..dav_common import dav_get_file
|
||||||
from ._misc import api_return_image
|
from ._misc import api_return_image
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ async def get_doors(
|
||||||
@router.put("/doors")
|
@router.put("/doors")
|
||||||
async def put_doors(
|
async def put_doors(
|
||||||
doors: DoorsSaved,
|
doors: DoorsSaved,
|
||||||
|
cfg: Config = Depends(get_config),
|
||||||
cal_cfg: CalendarConfig = Depends(get_calendar_config),
|
cal_cfg: CalendarConfig = Depends(get_calendar_config),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -54,4 +56,4 @@ async def put_doors(
|
||||||
doors,
|
doors,
|
||||||
key=lambda door: door.day,
|
key=lambda door: door.day,
|
||||||
)
|
)
|
||||||
await set_calendar_config(cal_cfg)
|
await set_calendar_config(cfg, cal_cfg)
|
||||||
|
|
Loading…
Reference in a new issue