Add SHOW_BLOCK_ALERT config option.

This commit is contained in:
Edward Betts 2020-04-22 16:30:44 +01:00
parent 95d69ef302
commit 3d113a593c
2 changed files with 15 additions and 6 deletions

11
app.py
View file

@ -113,8 +113,9 @@ def init_profile():
def global_user(): def global_user():
g.user = wikidata_oauth.get_username() g.user = wikidata_oauth.get_username()
@app.before_request def check_for_blocks():
def get_blocks(): if hasattr(g, 'server_ip'): # already done
return
hostname = app.config.get('HOSTNAME') hostname = app.config.get('HOSTNAME')
if not hostname: if not hostname:
return return
@ -127,6 +128,11 @@ def get_blocks():
except Exception: except Exception:
pass pass
@app.before_request
def get_blocks():
if app.config.get('SHOW_BLOCK_ALERT') is not False:
check_for_blocks()
@app.route('/find_more_setting') @app.route('/find_more_setting')
def flip_find_more(): def flip_find_more():
session['no_find_more'] = not session.get('no_find_more') session['no_find_more'] = not session.get('no_find_more')
@ -1075,6 +1081,7 @@ def wikidata_query_list():
@app.route('/report/blocks') @app.route('/report/blocks')
def server_block_report(): def server_block_report():
check_for_blocks()
return render_template('block_report.html') return render_template('block_report.html')

View file

@ -17,10 +17,12 @@
<body> <body>
{% block nav %}{{ navbar() }}{% endblock %} {% block nav %}{{ navbar() }}{% endblock %}
<div class="p-2"> {% if config.SHOW_BLOCK_ALERT %}
<div class="p-2">
{{ local_block_alert() }} {{ local_block_alert() }}
{{ global_block_alert() }} {{ global_block_alert() }}
</div> </div>
{% endif %}
{% block content %}{% endblock %} {% block content %}{% endblock %}