diff --git a/Ideen.md b/Ideen.md index b6a262f..5d12265 100644 --- a/Ideen.md +++ b/Ideen.md @@ -1,7 +1,6 @@ # MUSS - api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild) -- api: Config-Option "Überspringe leere Türchen" (standard ja) # KANN @@ -21,3 +20,4 @@ - `alert` durch bulma Komponente(n) ersetzen - 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) diff --git a/api/advent22_api/core/config.py b/api/advent22_api/core/config.py index 39cebb0..a518166 100644 --- a/api/advent22_api/core/config.py +++ b/api/advent22_api/core/config.py @@ -34,6 +34,9 @@ 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 diff --git a/api/advent22_api/core/depends.py b/api/advent22_api/core/depends.py index b95eea8..5a8f26a 100644 --- a/api/advent22_api/core/depends.py +++ b/api/advent22_api/core/depends.py @@ -34,23 +34,6 @@ async def get_all_sorted_days( return sorted(set(door.day for door in cal_cfg.doors)) -async def get_all_event_dates( - cfg: Config = Depends(get_config), - days: list[int] = Depends(get_all_sorted_days), -) -> EventDates: - """ - Aktueller Kalender-Zeitraum - """ - - return EventDates( - today=date.today(), - begin_month=cfg.puzzle.begin_month, - begin_day=cfg.puzzle.begin_day, - events=days, - close_after=cfg.puzzle.close_after, - ) - - async def get_all_parts( cfg: Config = Depends(get_config), days: list[int] = Depends(get_all_sorted_days), @@ -81,6 +64,27 @@ async def get_all_parts( return result +async def get_all_event_dates( + cfg: Config = Depends(get_config), + days: list[int] = Depends(get_all_sorted_days), + parts: dict[int, str] = Depends(get_all_parts), +) -> EventDates: + """ + Aktueller Kalender-Zeitraum + """ + + if cfg.puzzle.skip_empty: + days = [day for day in days if parts[day] != ""] + + return EventDates( + today=date.today(), + begin_month=cfg.puzzle.begin_month, + begin_day=cfg.puzzle.begin_day, + events=days, + close_after=cfg.puzzle.close_after, + ) + + async def get_all_auto_image_names( days: list[int] = Depends(get_all_sorted_days), images: list[str] = Depends(list_images_auto), diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index 45dc83a..aef84ee 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -36,6 +36,7 @@ class AdminConfigModel(BaseModel): clean: str class __Puzzle(BaseModel): + skip_empty: bool first: date next: date | None last: date @@ -87,6 +88,7 @@ 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, diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index eb0e9e4..dad5218 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -68,6 +68,10 @@
"{{ admin_config_model.puzzle.seed }}"
+ +
Leere Türchen
+
Überspringen
+
Anzeigen
@@ -195,6 +199,7 @@ export default class extends Vue { clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", }, puzzle: { + skip_empty: true, first: "2023-12-01", next: "2023-12-01", last: "2023-12-24", @@ -229,7 +234,7 @@ export default class extends Vue { public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string { const iso_date = this.admin_config_model.puzzle[name]; - if (iso_date === null) return "-"; + if (!(typeof iso_date == "string")) return "-"; return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT); } diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index f7a1874..aebd642 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -7,6 +7,7 @@ export interface AdminConfigModel { clean: string; }; puzzle: { + skip_empty: boolean; first: string; next: string | null; last: string;