From 0bbed0ced53c32c0afaa80e813a64ed06fa40d02 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 10 Jan 2021 12:17:14 +1100 Subject: [PATCH] renamed ClearMessage to better name of ClearStatus, and exposed it to jinja2 so status messages now work in base.html --- main.py | 6 ++++++ status.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1a8fa15..fdfd7e4 100644 --- a/main.py +++ b/main.py @@ -26,6 +26,12 @@ db = SQLAlchemy(app) ma = Marshmallow(app) Bootstrap(app) + +####################################### GLOBALS ####################################### +# allow jinja2 to call these python functions directly +app.jinja_env.globals['ClearStatus'] = st.ClearStatus + + @app.route("/test", methods=["GET"]) def test(): return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage()) diff --git a/status.py b/status.py index b0c30f4..ca6f9df 100644 --- a/status.py +++ b/status.py @@ -21,7 +21,7 @@ class Status: self.message=self.message+msg return - def ClearMessage(self): + def ClearStatus(self): self.alert="success" self.message="" return ""