Fix rendering when max_days is not specified

This commit is contained in:
Fabian Müller 2022-11-21 14:00:52 +01:00
parent bb2f840cec
commit 276110b2a2

View File

@ -40,9 +40,19 @@ async def generate_response(request: Request, template_name: str, **additional_c
@router.get("/sidebar/embed.html", response_class=HTMLResponse) @router.get("/sidebar/embed.html", response_class=HTMLResponse)
async def embed_sidebar(request: Request, max_days: int = None): async def embed_sidebar(request: Request, max_days: int = None):
return await generate_response(request, "sidebar/embed.html", max_days=int(max_days)) try:
max_days = int(max_days)
except TypeError:
pass
return await generate_response(request, "sidebar/embed.html", max_days=max_days)
@router.get("/sidebar/demo.html", response_class=HTMLResponse) @router.get("/sidebar/demo.html", response_class=HTMLResponse)
async def sidebar_demo(request: Request, max_days: int = None): async def sidebar_demo(request: Request, max_days: int = None):
return await generate_response(request, "sidebar/demo.html", max_days=int(max_days)) try:
max_days = int(max_days)
except TypeError:
pass
return await generate_response(request, "sidebar/demo.html", max_days=max_days)