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():
g.user = wikidata_oauth.get_username()
@app.before_request
def get_blocks():
def check_for_blocks():
if hasattr(g, 'server_ip'): # already done
return
hostname = app.config.get('HOSTNAME')
if not hostname:
return
@ -127,6 +128,11 @@ def get_blocks():
except Exception:
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')
def flip_find_more():
session['no_find_more'] = not session.get('no_find_more')
@ -1075,6 +1081,7 @@ def wikidata_query_list():
@app.route('/report/blocks')
def server_block_report():
check_for_blocks()
return render_template('block_report.html')

View file

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