mirrors: record deprecation reason

This commit is contained in:
Iain Learmonth 2022-05-01 16:23:45 +01:00
parent cacb35a671
commit 18e046dc42
9 changed files with 96 additions and 26 deletions

View file

@ -39,7 +39,8 @@ def portal_home():
last24 = len(Proxy.query.filter(Proxy.deprecated > (now - timedelta(days=1))).all())
last72 = len(Proxy.query.filter(Proxy.deprecated > (now - timedelta(days=3))).all())
lastweek = len(Proxy.query.filter(Proxy.deprecated > (now - timedelta(days=7))).all())
return render_template("home.html.j2", section="home", groups=groups, last24=last24, last72=last72, lastweek=lastweek, proxies=proxies)
return render_template("home.html.j2", section="home", groups=groups, last24=last24, last72=last72,
lastweek=lastweek, proxies=proxies)
@portal.route("/groups")
@ -168,7 +169,8 @@ def blocked_proxy(proxy_id):
message="The requested proxy could not be found."))
form = LifecycleForm()
if form.validate_on_submit():
proxy.deprecate()
proxy.deprecate(reason="manual")
db.session.commit()
flash("Proxy will be shortly replaced.", "success")
return redirect(url_for("portal.edit_origin", origin_id=proxy.origin.id))
return render_template("lifecycle.html.j2",
@ -204,6 +206,7 @@ def view_mirror_lists():
def destroy_mirror_list(list_id):
return "not implemented"
@portal.route("/list/new", methods=['GET', 'POST'])
@portal.route("/list/new/<group_id>", methods=['GET', 'POST'])
def new_mirror_list(group_id=None):
@ -325,14 +328,15 @@ def edit_bridgeconf(bridgeconf_id):
@portal.route("/bridge/block/<bridge_id>", methods=['GET', 'POST'])
def blocked_bridge(bridge_id):
bridge = Bridge.query.filter(Bridge.id == bridge_id, Bridge.destroyed == None).first()
bridge: Bridge = Bridge.query.filter(Bridge.id == bridge_id, Bridge.destroyed == None).first()
if bridge is None:
return Response(render_template("error.html.j2",
header="404 Proxy Not Found",
message="The requested bridge could not be found."))
form = LifecycleForm()
if form.validate_on_submit():
bridge.deprecate()
bridge.deprecate(reason="manual")
db.session.commit()
flash("Bridge will be shortly replaced.", "success")
return redirect(url_for("portal.edit_bridgeconf", bridgeconf_id=bridge.conf_id))
return render_template("lifecycle.html.j2",
@ -344,8 +348,8 @@ def blocked_bridge(bridge_id):
def response_404(message: str):
return Response(render_template("error.html.j2",
header="404 Not Found",
message=message))
header="404 Not Found",
message=message))
def view_lifecycle(*,
@ -361,7 +365,11 @@ def view_lifecycle(*,
if action == "destroy":
resource.destroy()
elif action == "deprecate":
resource.deprecate()
resource.deprecate(reason="manual")
else:
flash("Unknown action")
return redirect(url_for("portal.portal_home"))
db.session.commit()
flash(success_message, "success")
return redirect(url_for(success_view))
return render_template("lifecycle.html.j2",