router.html: Log blocked status changes to router events

Like normal router events, the block/unblock events are deleted
if they become old enough.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-02-10 13:18:22 +01:00
parent 3742f5415d
commit 84eb048904
2 changed files with 11 additions and 0 deletions

View File

@ -278,10 +278,20 @@ def router_info(dbid):
if request.form.get("blocked") == "true":
added = mysql.utcnow()
mysql.execute("INSERT INTO blocked (mac, added) VALUES (%s, %s)",(mac,added,))
mysql.execute("""
INSERT INTO router_events (router, time, type, comment)
VALUES (%s, %s, %s, %s)
""",(dbid,mysql.utcnow(),"admin","Marked as blocked",))
mysql.commit()
else:
mysql.execute("DELETE FROM blocked WHERE mac = %s",(mac,))
mysql.execute("""
INSERT INTO router_events (router, time, type, comment)
VALUES (%s, %s, %s, %s)
""",(dbid,mysql.utcnow(),"admin","Removed blocked status",))
mysql.commit()
router["events"] = mysql.fetchall("""SELECT * FROM router_events WHERE router = %s""",(dbid,))
router["events"] = mysql.utcawaretuple(router["events"],"time")
else:
flash("<b>You are not authorized to perform this action!</b>", "danger")
elif request.form.get("act") == "report":

View File

@ -157,6 +157,7 @@ def status2css(status):
"netmon": "primary",
"update": "primary",
"orphaned": "default",
"admin": "warning",
}
return "label label-%s" % status_map.get(status, "default")