diff --git a/api/advent22_api/core/config.py b/api/advent22_api/core/config.py index 29f7cb1..fe24823 100644 --- a/api/advent22_api/core/config.py +++ b/api/advent22_api/core/config.py @@ -78,9 +78,6 @@ class Puzzle(BaseModel): # TODO penner neue Route GET /user/title title: str - # Lösungswort - solution: TransformedString - # Tag, an dem der Kalender startet # TODO penner begin_day: int = 1 @@ -117,7 +114,13 @@ class Image(BaseModel): class Config(BaseModel): + # Login-Daten für Admin-Modus admin: User + + # Lösungswort + solution: TransformedString + + # Weitere Einstellungen puzzle: Puzzle image: Image diff --git a/api/advent22_api/core/depends.py b/api/advent22_api/core/depends.py index 5a5a160..00b45dd 100644 --- a/api/advent22_api/core/depends.py +++ b/api/advent22_api/core/depends.py @@ -46,7 +46,7 @@ async def get_all_parts( Lösung auf vorhandene Tage aufteilen """ - solution_length = len(cfg.puzzle.solution.clean) + solution_length = len(cfg.solution.clean) num_days = len(days) rnd = await Random.get() @@ -60,7 +60,7 @@ async def get_all_parts( ] result: dict[int, str] = {} - for day, letter in zip(solution_days, cfg.puzzle.solution.clean): + for day, letter in zip(solution_days, cfg.solution.clean): result[day] = result.get(day, "") result[day] += letter diff --git a/api/advent22_api/core/helpers.py b/api/advent22_api/core/helpers.py index 8c5f186..07365dd 100644 --- a/api/advent22_api/core/helpers.py +++ b/api/advent22_api/core/helpers.py @@ -18,7 +18,7 @@ class Random(random.Random): @classmethod async def get(cls, bonus_salt: Any = "") -> Self: cfg = await get_config() - return cls(f"{cfg.puzzle.solution.clean}{cfg.random_seed}{bonus_salt}") + return cls(f"{cfg.solution.clean}{cfg.random_seed}{bonus_salt}") def shuffled(self, population: Sequence[T]) -> Sequence[T]: return self.sample(population, k=len(population)) diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index 9464107..70fb6fd 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -22,8 +22,13 @@ async def is_admin( class ConfigModel(BaseModel): + class __Solution(BaseModel): + value: str + whitespace: str | None + case: str | None + clean: str + class __Puzzle(BaseModel): - solution: str first: date next: date | None last: date @@ -39,6 +44,7 @@ class ConfigModel(BaseModel): cache_ttl: int config_file: str + solution: __Solution puzzle: __Puzzle calendar: __Calendar image: Image @@ -58,8 +64,13 @@ async def get_config_model( return ConfigModel.model_validate( { + "solution": { + "value": cfg.solution.value, + "whitespace": cfg.solution.whitespace, + "case": cfg.solution.case, + "clean": cfg.solution.clean, + }, "puzzle": { - "solution": cfg.puzzle.solution.clean, "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 2139cfa..012c9da 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -4,17 +4,43 @@
+

Lösung

+
+
Wert
+
+ Eingabe: + + "{{ config_model.solution.value }}" + +
+
+ Ausgabe: + + "{{ config_model.solution.clean }}" + +
+ +
Transformation
+
+ Whitespace: + + {{ config_model.solution.whitespace }} + +
+
+ Buchstaben: + + {{ config_model.solution.case }} + +
+
+

Rätsel

Titel
Advent22
-
Lösung
-
- "{{ config_model.puzzle.solution }}" -
-
Offene Türchen
{{ num_user_doors }}
@@ -143,8 +169,13 @@ import CountDown from "../CountDown.vue"; }) export default class extends Vue { public config_model: ConfigModel = { + solution: { + value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + whitespace: null, + case: null, + clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + }, puzzle: { - solution: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", first: "2023-12-01", next: "2023-12-01", last: "2023-12-24", diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index e842d01..a2a808c 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -1,6 +1,11 @@ export interface ConfigModel { + solution: { + value: string; + whitespace: string | null; + case: string | null; + clean: string; + }; puzzle: { - solution: string; first: string; next: string | null; last: string;