mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
use EventDays in GET admin/config_model
This commit is contained in:
parent
a4a0893e7d
commit
c93ec06925
4 changed files with 36 additions and 16 deletions
|
@ -1,3 +1,4 @@
|
|||
from datetime import date
|
||||
from io import BytesIO
|
||||
from typing import cast
|
||||
|
||||
|
@ -7,7 +8,7 @@ from PIL import Image, ImageFont
|
|||
from .advent_image import _XY, AdventImage
|
||||
from .calendar_config import CalendarConfig, get_calendar_config
|
||||
from .config import Config, get_config
|
||||
from .helpers import Random, list_images_auto, load_image, set_len
|
||||
from .helpers import EventDays, Random, list_images_auto, load_image, set_len
|
||||
from .webdav import WebDAV
|
||||
|
||||
|
||||
|
@ -21,6 +22,22 @@ async def get_all_days(
|
|||
return sorted(set(door.day for door in cal_cfg.doors))
|
||||
|
||||
|
||||
async def get_all_event_days(
|
||||
days: list[int] = Depends(get_all_days),
|
||||
) -> EventDays:
|
||||
"""
|
||||
Aktuelles EventDays Objekt
|
||||
"""
|
||||
|
||||
return EventDays.get(
|
||||
today=date.today(),
|
||||
begin_month=12,
|
||||
begin_day=1,
|
||||
events_after=[day - 1 for day in days],
|
||||
closing_after=90,
|
||||
)
|
||||
|
||||
|
||||
async def get_all_parts(
|
||||
cfg: Config = Depends(get_config),
|
||||
days: list[int] = Depends(get_all_days),
|
||||
|
|
|
@ -3,9 +3,11 @@ from datetime import date
|
|||
from fastapi import APIRouter, Depends
|
||||
from pydantic import BaseModel
|
||||
|
||||
from advent22_api.core.helpers import EventDays
|
||||
|
||||
from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config
|
||||
from ..core.config import Config, get_config
|
||||
from ..core.depends import get_all_image_names, get_all_parts
|
||||
from ..core.depends import get_all_event_days, get_all_image_names, get_all_parts
|
||||
from ..core.settings import SETTINGS
|
||||
from ._security import require_admin, user_is_admin
|
||||
|
||||
|
@ -22,9 +24,9 @@ async def is_admin(
|
|||
class ConfigModel(BaseModel):
|
||||
class __Puzzle(BaseModel):
|
||||
solution: str
|
||||
begin: date
|
||||
first: date
|
||||
last: date
|
||||
end: date
|
||||
closing: date
|
||||
seed: str
|
||||
|
||||
class __Calendar(BaseModel):
|
||||
|
@ -56,6 +58,7 @@ async def get_config_model(
|
|||
_: None = Depends(require_admin),
|
||||
cfg: Config = Depends(get_config),
|
||||
cal_cfg: CalendarConfig = Depends(get_calendar_config),
|
||||
event_days: EventDays = Depends(get_all_event_days),
|
||||
) -> ConfigModel:
|
||||
"""
|
||||
Kombiniert aus privaten `settings`, `config` und `calendar_config`
|
||||
|
@ -65,9 +68,9 @@ async def get_config_model(
|
|||
{
|
||||
"puzzle": {
|
||||
"solution": cfg.puzzle.solution,
|
||||
"begin": date.today(), # TODO
|
||||
"end": date.today(), # TODO
|
||||
"closing": date.today(), # TODO
|
||||
"first": event_days.first,
|
||||
"last": event_days.last,
|
||||
"end": event_days.end,
|
||||
"seed": cfg.puzzle.random_seed,
|
||||
},
|
||||
"calendar": {
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
<dd>dd-hh-mm-ss</dd>
|
||||
|
||||
<dt>Erstes Türchen</dt>
|
||||
<dd>{{ config_model.puzzle.begin }}</dd>
|
||||
<dd>{{ config_model.puzzle.first }}</dd>
|
||||
|
||||
<dt>Letztes Türchen</dt>
|
||||
<dd>{{ config_model.puzzle.end }}</dd>
|
||||
<dd>{{ config_model.puzzle.last }}</dd>
|
||||
|
||||
<dt>Rätsel schließt</dt>
|
||||
<dd>{{ config_model.puzzle.closing }}</dd>
|
||||
<dt>Rätsel schließt nach</dt>
|
||||
<dd>{{ config_model.puzzle.end }}</dd>
|
||||
|
||||
<dt>Zufalls-Seed</dt>
|
||||
<dd class="is-family-monospace">
|
||||
|
@ -142,9 +142,9 @@ export default class extends Vue {
|
|||
public config_model: ConfigModel = {
|
||||
puzzle: {
|
||||
solution: "ABCDEFGHIJKLMNOPQRSTUVWX",
|
||||
begin: "01.12.2023",
|
||||
end: "24.12.2023",
|
||||
closing: "01.04.2024",
|
||||
first: "01.12.2023",
|
||||
last: "24.12.2023",
|
||||
end: "01.04.2024",
|
||||
seed: "",
|
||||
},
|
||||
calendar: {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
export interface ConfigModel {
|
||||
puzzle: {
|
||||
solution: string;
|
||||
begin: string;
|
||||
first: string;
|
||||
last: string;
|
||||
end: string;
|
||||
closing: string;
|
||||
seed: string;
|
||||
};
|
||||
calendar: {
|
||||
|
|
Loading…
Reference in a new issue