From b7d67bf5fcf02d172fce1a290c500f9fb432c49f Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sat, 19 Jun 2021 05:06:24 -0700 Subject: [PATCH] render_template: convert HTTPStatus objects This will automate a lot of conversion that happens around the codebase in terms of status_code. As of this commit, we should improve usage and remove int(status_code) casts wherever we can. Signed-off-by: Kevin Morris --- aurweb/templates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aurweb/templates.py b/aurweb/templates.py index c0472b2e..7474da1c 100644 --- a/aurweb/templates.py +++ b/aurweb/templates.py @@ -65,7 +65,7 @@ async def make_variable_context(request: Request, title: str, next: str = None): def render_template(request: Request, path: str, context: dict, - status_code=int(HTTPStatus.OK)): + status_code: HTTPStatus = HTTPStatus.OK): """ Render a Jinja2 multi-lingual template with some context. """ # Create a deep copy of our jinja2 environment. The environment in @@ -81,7 +81,7 @@ def render_template(request: Request, template = templates.get_template(path) rendered = template.render(context) - response = HTMLResponse(rendered, status_code=status_code) + response = HTMLResponse(rendered, status_code=int(status_code)) response.set_cookie("AURLANG", context.get("language")) response.set_cookie("AURTZ", context.get("timezone")) return response