From 42153f2e2773081df38af66bb003fbed60992357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Mon, 21 Nov 2022 11:44:38 +0100 Subject: [PATCH] Add max_days query parameter --- fabcal/routers/frontend.py | 4 ++-- templates/sidebar/includes/events-list.html | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fabcal/routers/frontend.py b/fabcal/routers/frontend.py index 19d9c6a..68950a5 100644 --- a/fabcal/routers/frontend.py +++ b/fabcal/routers/frontend.py @@ -39,5 +39,5 @@ async def generate_response(request: Request, template_name: str, **additional_c @router.get("/sidebar/embed.html", response_class=HTMLResponse) -async def embed_sidebar(request: Request): - return await generate_response(request, "sidebar/embed.html") +async def embed_sidebar(request: Request, max_days: int = None): + return await generate_response(request, "sidebar/embed.html", max_days=int(max_days)) diff --git a/templates/sidebar/includes/events-list.html b/templates/sidebar/includes/events-list.html index 03ed66d..151aa05 100644 --- a/templates/sidebar/includes/events-list.html +++ b/templates/sidebar/includes/events-list.html @@ -1,3 +1,7 @@ +{% if max_days %} +{% set grouped_events = grouped_events[:max_days] %} +{% endif %} + {% for start_date, events in grouped_events %}