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
|
||||
|
||||
- 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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -68,6 +68,10 @@
|
|||
<dd class="is-family-monospace">
|
||||
"{{ admin_config_model.puzzle.seed }}"
|
||||
</dd>
|
||||
|
||||
<dt>Leere Türchen</dt>
|
||||
<dd v-if="admin_config_model.puzzle.skip_empty">Überspringen</dd>
|
||||
<dd v-else>Anzeigen</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ export interface AdminConfigModel {
|
|||
clean: string;
|
||||
};
|
||||
puzzle: {
|
||||
skip_empty: boolean;
|
||||
first: string;
|
||||
next: string | null;
|
||||
last: string;
|
||||
|
|
Loading…
Reference in a new issue