From ad5b108ec03f2cc8f3053647a7c8c003a3c3148a Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Fri, 28 Jul 2023 17:10:36 +0200 Subject: [PATCH] Fix 404 page crash The 404 page crashes when the user is logged in: File "/home/zorun/code/ihatemoney/ihatemoney/templates/404.html", line 1, in top-level template code {% extends "layout.html" %} File "/home/zorun/code/ihatemoney/ihatemoney/templates/layout.html", line 124, in top-level template code {{ g.logout_form.hidden_tag() }} File "/home/zorun/venv/py3-ihatemoney/lib/python3.9/site-packages/jinja2/environment.py", line 474, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'flask.ctx._AppCtxGlobals object' has no attribute 'logout_form' This is because the logout form is defined by a URL processor, and this does not seem to apply for all pages. To solve this, simply skip the logout form if it's not defined. --- ihatemoney/templates/layout.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ihatemoney/templates/layout.html b/ihatemoney/templates/layout.html index 9cfd2cef..415113b4 100644 --- a/ihatemoney/templates/layout.html +++ b/ihatemoney/templates/layout.html @@ -119,12 +119,14 @@ {% if session['is_admin'] %}
  • {{ _("Dashboard") }}
  • {% endif %} + {% if g.logout_form %}
  • {{ g.logout_form.hidden_tag() }} {{ g.logout_form.submit(class="dropdown-item") }}
  • + {% endif %} {% endif %}