Add block list report to show active blocks

This commit is contained in:
Edward Betts 2020-04-22 14:22:33 +01:00
parent 3bbb25226b
commit 95d69ef302
5 changed files with 102 additions and 0 deletions

View file

@ -12,9 +12,16 @@
{% block style %}{% endblock %}
</head>
{% from "navbar.html" import navbar with context %}
{% from "block_alert.html" import local_block_alert, global_block_alert with context %}
<body>
{% block nav %}{{ navbar() }}{% endblock %}
<div class="p-2">
{{ local_block_alert() }}
{{ global_block_alert() }}
</div>
{% block content %}{% endblock %}
<script src="{{ url_for('static', filename='javascript/jquery/jquery.min.js') }}"></script>

View file

@ -0,0 +1,25 @@
{% macro local_block_alert() %}
{% if g.local_blocks %}
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Wikidata IP block preventing edits</h4>
<p>Editing is currently unavailable due to a block of the server that hosts this tool.</p>
{% if request.endpoint != 'server_block_report' %}
<hr>
<p class="mb-0">See the <a href="{{ url_for('server_block_report') }}">block report</a> for more details.</p>
{% endif %}
</div>
{% endif %}
{% endmacro %}
{% macro global_block_alert() %}
{% if g.global_blocks %}
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Wikimedia global IP block preventing edits</h4>
<p>Editing is currently unavailable due to a block of the server that hosts this tool.</p>
{% if request.endpoint != 'server_block_report' %}
<hr>
<p class="mb-0">See the <a href="{{ url_for('server_block_report') }}">block report</a> for more details.</p>
{% endif %}
</div>
{% endif %}
{% endmacro %}

View file

@ -0,0 +1,47 @@
{% extends "base.html" %}
{% macro block_list(blocks) %}
{% for i in blocks %}
<dl class="row">
{% for key, value in i.items() %}
<dt class="col-sm-1">{{ key }}</dt>
<dd class="col-sm-11">{{ value }}</dt>
{% endfor %}
</dl>
{% endfor %}
{% endmacro %}
{% block content %}
<div class="p-2">
<h1>Block report</h1>
<p>This report shows IP blocks on Wikidata that will prevent changes being saved.</p>
<ul>
<li>Server hostname: {{ config.HOSTNAME }}</li>
<li>Server IP: {{ g.server_ip }}</li>
</ul>
<h4>Local blocks on Wikidata</h4>
{% set url = 'https://www.wikidata.org/wiki/Special:BlockList?wpTarget=' + g.server_ip %}
<p><a href="{{ url }}">Check block list on Wikidata</a></p>
{% if g.local_blocks %}
{{ block_list(g.local_blocks) }}
{% else %}
<p>There are no local blocks for the server IP address on Wikidata</p>
{% endif %}
<h4>Global blocks</h4>
{% set url = 'https://www.wikidata.org/wiki/Special:GlobalBlockList/' + g.server_ip %}
<p><a href="{{ url }}">Check global block list</a></p>
{% if g.global_blocks %}
{{ block_list(g.global_blocks) }}
{% else %}
<p>There are no global blocks for the server IP address</p>
{% endif %}
</div>
{% endblock %}