mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-22 15:53:01 +00:00
implement cfg.puzzle.skip_empty
This commit is contained in:
parent
d66019f53c
commit
082f50c66b
6 changed files with 34 additions and 19 deletions
2
Ideen.md
2
Ideen.md
|
@ -1,7 +1,6 @@
|
||||||
# MUSS
|
# MUSS
|
||||||
|
|
||||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||||
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
|
||||||
|
|
||||||
# KANN
|
# KANN
|
||||||
|
|
||||||
|
@ -21,3 +20,4 @@
|
||||||
- `alert` durch bulma Komponente(n) ersetzen
|
- `alert` durch bulma Komponente(n) ersetzen
|
||||||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||||
|
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
||||||
|
|
|
@ -34,6 +34,9 @@ class Site(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class Puzzle(BaseModel):
|
class Puzzle(BaseModel):
|
||||||
|
# Türchen ohne Buchstabe überspringen
|
||||||
|
skip_empty: bool = True
|
||||||
|
|
||||||
# Tag, an dem der Kalender startet
|
# Tag, an dem der Kalender startet
|
||||||
begin_day: int = 1
|
begin_day: int = 1
|
||||||
|
|
||||||
|
|
|
@ -34,23 +34,6 @@ async def get_all_sorted_days(
|
||||||
return sorted(set(door.day for door in cal_cfg.doors))
|
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(
|
async def get_all_parts(
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
days: list[int] = Depends(get_all_sorted_days),
|
days: list[int] = Depends(get_all_sorted_days),
|
||||||
|
@ -81,6 +64,27 @@ async def get_all_parts(
|
||||||
return result
|
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(
|
async def get_all_auto_image_names(
|
||||||
days: list[int] = Depends(get_all_sorted_days),
|
days: list[int] = Depends(get_all_sorted_days),
|
||||||
images: list[str] = Depends(list_images_auto),
|
images: list[str] = Depends(list_images_auto),
|
||||||
|
|
|
@ -36,6 +36,7 @@ class AdminConfigModel(BaseModel):
|
||||||
clean: str
|
clean: str
|
||||||
|
|
||||||
class __Puzzle(BaseModel):
|
class __Puzzle(BaseModel):
|
||||||
|
skip_empty: bool
|
||||||
first: date
|
first: date
|
||||||
next: date | None
|
next: date | None
|
||||||
last: date
|
last: date
|
||||||
|
@ -87,6 +88,7 @@ async def get_config_model(
|
||||||
"clean": cfg.solution.clean,
|
"clean": cfg.solution.clean,
|
||||||
},
|
},
|
||||||
"puzzle": {
|
"puzzle": {
|
||||||
|
"skip_empty": cfg.puzzle.skip_empty,
|
||||||
"first": event_dates.first,
|
"first": event_dates.first,
|
||||||
"next": event_dates.next,
|
"next": event_dates.next,
|
||||||
"last": event_dates.last,
|
"last": event_dates.last,
|
||||||
|
|
|
@ -68,6 +68,10 @@
|
||||||
<dd class="is-family-monospace">
|
<dd class="is-family-monospace">
|
||||||
"{{ admin_config_model.puzzle.seed }}"
|
"{{ admin_config_model.puzzle.seed }}"
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt>Leere Türchen</dt>
|
||||||
|
<dd v-if="admin_config_model.puzzle.skip_empty">Überspringen</dd>
|
||||||
|
<dd v-else>Anzeigen</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -195,6 +199,7 @@ export default class extends Vue {
|
||||||
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
},
|
},
|
||||||
puzzle: {
|
puzzle: {
|
||||||
|
skip_empty: true,
|
||||||
first: "2023-12-01",
|
first: "2023-12-01",
|
||||||
next: "2023-12-01",
|
next: "2023-12-01",
|
||||||
last: "2023-12-24",
|
last: "2023-12-24",
|
||||||
|
@ -229,7 +234,7 @@ export default class extends Vue {
|
||||||
|
|
||||||
public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
|
public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
|
||||||
const iso_date = this.admin_config_model.puzzle[name];
|
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);
|
return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ export interface AdminConfigModel {
|
||||||
clean: string;
|
clean: string;
|
||||||
};
|
};
|
||||||
puzzle: {
|
puzzle: {
|
||||||
|
skip_empty: boolean;
|
||||||
first: string;
|
first: string;
|
||||||
next: string | null;
|
next: string | null;
|
||||||
last: string;
|
last: string;
|
||||||
|
|
Loading…
Reference in a new issue