Fix template context
This commit is contained in:
parent
9b8da8c2b6
commit
3dc8a7f232
@ -1,5 +1,3 @@
|
|||||||
import base64
|
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import babel.dates
|
import babel.dates
|
||||||
@ -28,31 +26,16 @@ async def generate_response(request: Request, template_name: str, **additional_c
|
|||||||
def localized_abbreviated_weekday(dt: datetime):
|
def localized_abbreviated_weekday(dt: datetime):
|
||||||
return babel.dates.format_datetime(dt, format="%b", locale="de_DE")
|
return babel.dates.format_datetime(dt, format="%b", locale="de_DE")
|
||||||
|
|
||||||
def base64_encode(s: str):
|
|
||||||
return base64.b64encode(s.encode()).decode()
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"request": request,
|
"request": request,
|
||||||
"grouped_events": grouped_events,
|
"grouped_events": grouped_events,
|
||||||
"dir": dir,
|
|
||||||
"localized_abbreviated_month": localized_abbreviated_month,
|
"localized_abbreviated_month": localized_abbreviated_month,
|
||||||
"localized_abbreviated_weekday": localized_abbreviated_weekday,
|
"localized_abbreviated_weekday": localized_abbreviated_weekday,
|
||||||
"base64_encode": base64_encode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.update(additional_context)
|
context.update(additional_context)
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(template_name, context=context)
|
||||||
template_name,
|
|
||||||
context={
|
|
||||||
"request": request,
|
|
||||||
"grouped_events": grouped_events,
|
|
||||||
"dir": dir,
|
|
||||||
"localized_abbreviated_month": localized_abbreviated_month,
|
|
||||||
"localized_abbreviated_weekday": localized_abbreviated_weekday,
|
|
||||||
"base64_encode": base64_encode,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/sidebar/embed.html", response_class=HTMLResponse)
|
@router.get("/sidebar/embed.html", response_class=HTMLResponse)
|
||||||
|
Loading…
Reference in New Issue
Block a user