feat: adds report for blocks today
This commit is contained in:
parent
d84d74ae0f
commit
64c6414fb8
3 changed files with 50 additions and 1 deletions
|
@ -16,6 +16,7 @@ from app.extensions import migrate
|
|||
from app.extensions import bootstrap
|
||||
from app.models.automation import Automation, AutomationState
|
||||
from app.portal import portal
|
||||
from app.portal.report import report
|
||||
from app.tfstate import tfstate
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -31,7 +32,7 @@ bootstrap.init_app(app)
|
|||
|
||||
app.register_blueprint(portal, url_prefix="/portal")
|
||||
app.register_blueprint(tfstate, url_prefix="/tfstate")
|
||||
|
||||
app.register_blueprint(report, url_prefix="/report")
|
||||
|
||||
def not_migrating() -> bool:
|
||||
return len(sys.argv) < 2 or sys.argv[1] != "db"
|
||||
|
|
21
app/portal/report.py
Normal file
21
app/portal/report.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from flask import Blueprint, render_template
|
||||
from flask.typing import ResponseReturnValue
|
||||
from sqlalchemy import func, and_
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.mirrors import Proxy, Origin
|
||||
|
||||
report = Blueprint("report", __name__)
|
||||
|
||||
|
||||
@report.route("/blocks", methods=['GET'])
|
||||
def report_blocks() -> ResponseReturnValue:
|
||||
blocked_today = db.session.query(
|
||||
Origin.domain_name,
|
||||
Origin.description,
|
||||
Proxy.added,
|
||||
Proxy.deprecated,
|
||||
Proxy.deprecation_reason
|
||||
).join(Origin, Origin.id == Proxy.origin_id
|
||||
).filter(and_(Proxy.deprecated > func.current_date(), Proxy.deprecation_reason.like('block_%'))).all()
|
||||
return render_template("report_blocks.html.j2", blocked_today=blocked_today)
|
27
app/portal/templates/report_blocks.html.j2
Normal file
27
app/portal/templates/report_blocks.html.j2
Normal file
|
@ -0,0 +1,27 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bypass Censorship</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Blocked Today</h2>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Origin</th>
|
||||
<th>Blocked</th>
|
||||
<th>Detection Source</th>
|
||||
<th>Lifetime</th>
|
||||
</tr>
|
||||
{% for block in blocked_today %}
|
||||
<tr>
|
||||
<td><a href="https://{{ block.domain_name }}">{{ block.domain_name }}</a> ({{ block.description }})</td>
|
||||
<td>{{ block.deprecated }}</td>
|
||||
<td>{{ block.deprecation_reason }}</td>
|
||||
<td>{{ block.deprecated - block.added }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue