From 2d0209ae61b5db3fd1e1042aa284ff26f329c277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 12 Sep 2023 21:06:52 +0000 Subject: [PATCH] ConfigView.num_user_doors --- api/advent22_api/routers/user.py | 13 ++++++++++++- ui/src/components/ConfigView.vue | 11 +++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/api/advent22_api/routers/user.py b/api/advent22_api/routers/user.py index 732118a..daf511d 100644 --- a/api/advent22_api/routers/user.py +++ b/api/advent22_api/routers/user.py @@ -2,7 +2,7 @@ from fastapi import APIRouter, Depends, HTTPException, status from fastapi.responses import StreamingResponse from PIL import Image -from ..core.calendar_config import CalendarConfig, get_calendar_config +from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config from ..core.depends import get_day_image from ..core.helpers import api_return_image, load_image from ._security import user_can_view_day, user_is_admin @@ -41,3 +41,14 @@ async def get_image_for_day( raise HTTPException(status.HTTP_401_UNAUTHORIZED, "Wie unhöflich!!!") return await api_return_image(image) + + +@router.get("/doors") +async def get_doors( + cal_cfg: CalendarConfig = Depends(get_calendar_config), +) -> DoorsSaved: + """ + User-sichtbare Türchen lesen + """ + + return [door for door in cal_cfg.doors if await user_can_view_day(door.day)] diff --git a/ui/src/components/ConfigView.vue b/ui/src/components/ConfigView.vue index eeb6e22..ec9d336 100644 --- a/ui/src/components/ConfigView.vue +++ b/ui/src/components/ConfigView.vue @@ -18,8 +18,7 @@
{{ config_model.puzzle.solution }}
Offene Türchen
- -
10
+
{{ num_user_doors }}
Nächstes Türchen in
@@ -122,7 +121,7 @@