Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>
Add a visual aid to check the environment
core/app.py | 10 +++++++++- core/templates/layout.html | 13 +++++++++++++
diff --git a/core/app.py b/core/app.py index 6d8d9e63ebeb930adedba49166da38ba5ee8368a..08773425a98f3b89e22d7396abceae36b20aa054 100644 --- a/core/app.py +++ b/core/app.py @@ -1,7 +1,7 @@ from flask import Flask, render_template from flask_login import LoginManager -from core.config import read_from_config +from core.config import read_from_config, env from core.database import db, init_database app = Flask(__name__) @@ -33,3 +33,11 @@ @app.errorhandler(404) def handle_404(e): return render_template("not_found.html"), 404 + +@app.context_processor +def inject(): + ctx = { + 'environment': env, + } + + return ctx diff --git a/core/templates/layout.html b/core/templates/layout.html index 51d2c3f33053bc6e51523394c5077c7d91d0ce13..478cb167d55fe9ce9350b1cfde1d2428ae63ed01 100644 --- a/core/templates/layout.html +++ b/core/templates/layout.html @@ -11,6 +11,19 @@ </head> <body> + {% if environment != "production" or + (current_user and current_user.is_admin() )%} + <div style=" + {% if environment == "production" %} + background: #cc0022; + {% else %} + background: #228800; + {% endif %} + color: white; font-weight: bold; width: 100%; text-align: center"> + {{environment.upper()}} ENVIRONMENT + </div> + {% endif %} + <nav class="navbar container"> <a href="{{ url_for('basic.index') }}">Bem da Terra</a> <ul>