mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
GET user/next_door
This commit is contained in:
parent
41368c7191
commit
6bd8f66527
1 changed files with 21 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
|||
from datetime import datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.responses import StreamingResponse
|
||||
from PIL import Image
|
||||
|
||||
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 ..core.depends import get_all_event_days, get_day_image
|
||||
from ..core.helpers import EventDays, api_return_image, load_image
|
||||
from ._security import user_can_view_day, user_is_admin
|
||||
|
||||
router = APIRouter(prefix="/user", tags=["user"])
|
||||
|
@ -52,3 +54,20 @@ async def get_doors(
|
|||
"""
|
||||
|
||||
return [door for door in cal_cfg.doors if await user_can_view_day(door.day)]
|
||||
|
||||
|
||||
@router.get("/next_door")
|
||||
async def get_next_door(
|
||||
event_days: EventDays = Depends(get_all_event_days),
|
||||
) -> int | None:
|
||||
"""
|
||||
Zeit in ms, bis das nächste Türchen öffnet
|
||||
"""
|
||||
|
||||
if event_days.next is None:
|
||||
return None
|
||||
|
||||
dt = datetime.combine(event_days.next, datetime.min.time())
|
||||
td = dt - datetime.now()
|
||||
|
||||
return int(td.total_seconds() * 1000)
|
||||
|
|
Loading…
Reference in a new issue