diff --git a/Ideen.md b/Ideen.md index 5d12265..14c9e23 100644 --- a/Ideen.md +++ b/Ideen.md @@ -1,6 +1,5 @@ # MUSS -- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild) # KANN @@ -21,3 +20,4 @@ - api: admin Login case sensitivity (username "admin" == "AdMiN") - api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen - api: Config-Option "Überspringe leere Türchen" (standard ja) +- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild) diff --git a/api/advent22_api/core/config.py b/api/advent22_api/core/config.py index a518166..8811661 100644 --- a/api/advent22_api/core/config.py +++ b/api/advent22_api/core/config.py @@ -34,9 +34,6 @@ class Site(BaseModel): class Puzzle(BaseModel): - # Türchen ohne Buchstabe überspringen - skip_empty: bool = True - # Tag, an dem der Kalender startet begin_day: int = 1 @@ -46,6 +43,12 @@ class Puzzle(BaseModel): # Kalender so viele Tage nach der letzten Türöffnung schließen close_after: int = 90 + # Tage, für die kein Buchstabe vorgesehen wird + extra_days: set[int] = set() + + # Türchen ohne Buchstabe überspringen + skip_empty: bool = True + class Image(BaseModel): # Quadrat, Seitenlänge in px diff --git a/api/advent22_api/core/depends.py b/api/advent22_api/core/depends.py index 5a8f26a..dd28a8b 100644 --- a/api/advent22_api/core/depends.py +++ b/api/advent22_api/core/depends.py @@ -1,5 +1,4 @@ import re -from collections import defaultdict from dataclasses import dataclass from datetime import date from io import BytesIO @@ -42,6 +41,11 @@ async def get_all_parts( Lösung auf vorhandene Tage aufteilen """ + # noch keine Buchstaben verteilt + result = {day: "" for day in days} + # extra-Tage ausfiltern + days = [day for day in days if day not in cfg.puzzle.extra_days] + solution_length = len(cfg.solution.clean) num_days = len(days) @@ -55,12 +59,9 @@ async def get_all_parts( *rnd.sample(days, solution_length % num_days), ] - result: defaultdict[int, str] = defaultdict(str) for day, letter in zip(solution_days, cfg.solution.clean): result[day] += letter - result |= {missed_day: "" for missed_day in set(days) - set(result.keys())} - return result @@ -74,7 +75,7 @@ async def get_all_event_dates( """ if cfg.puzzle.skip_empty: - days = [day for day in days if parts[day] != ""] + days = [day for day in days if parts[day] != "" or day in cfg.puzzle.extra_days] return EventDates( today=date.today(), diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index aef84ee..ee5bb4b 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -36,12 +36,13 @@ class AdminConfigModel(BaseModel): clean: str class __Puzzle(BaseModel): - skip_empty: bool first: date next: date | None last: date end: date seed: str + extra_days: list[int] + skip_empty: bool class __Calendar(BaseModel): config_file: str @@ -88,12 +89,13 @@ async def get_config_model( "clean": cfg.solution.clean, }, "puzzle": { - "skip_empty": cfg.puzzle.skip_empty, "first": event_dates.first, "next": event_dates.next, "last": event_dates.last, "end": event_dates.end, "seed": cfg.random_seed, + "extra_days": sorted(cfg.puzzle.extra_days), + "skip_empty": cfg.puzzle.skip_empty, }, "calendar": { "config_file": cfg.calendar, diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index dad5218..d0ce3db 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -69,6 +69,19 @@ "{{ admin_config_model.puzzle.seed }}" +