diff --git a/files/classes/usermute.py b/files/classes/usermute.py index 5f572fa73..10db9750d 100644 --- a/files/classes/usermute.py +++ b/files/classes/usermute.py @@ -1,6 +1,7 @@ import time from sqlalchemy import Column, ForeignKey +from sqlalchemy.orm import relationship from sqlalchemy.sql.sqltypes import * from files.classes import Base @@ -11,6 +12,9 @@ class UserMute(Base): target_id = Column(Integer, ForeignKey("users.id"), primary_key=True) created_utc = Column(Integer) + user = relationship("User", primaryjoin="User.id==UserMute.user_id") + target = relationship("User", primaryjoin="User.id==UserMute.target_id") + def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) super().__init__(*args, **kwargs) diff --git a/files/routes/static.py b/files/routes/static.py index 214758941..83848e5d3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -9,6 +9,7 @@ from files.classes.award import AWARDS from files.classes.badges import Badge, BadgeDef from files.classes.mod_logs import ModAction from files.classes.userblock import UserBlock +from files.classes.usermute import UserMute from files.helpers.actions import * from files.helpers.alerts import * from files.helpers.config.const import * @@ -337,17 +338,17 @@ def badges(v): badges, counts = badge_list(SITE, v.admin_level >= PERMS['VIEW_PATRONS']) return render_template("badges.html", v=v, badges=badges, counts=counts) -@app.get("/blocks") +@app.get("/notification_mutes") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required -def blocks(v): - blocks = g.db.query(UserBlock).options( - joinedload(UserBlock.user), - joinedload(UserBlock.target), - ).order_by(UserBlock.created_utc.desc()) +def mutes(v): + mutes = g.db.query(UserMute).options( + joinedload(UserMute.user), + joinedload(UserMute.target), + ).order_by(UserMute.created_utc.desc()) - return render_template("blocks.html", v=v, blocks=blocks) + return render_template("notification_mutes.html", v=v, mutes=mutes) @app.get("/formatting") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) diff --git a/files/templates/notification_mutes.html b/files/templates/notification_mutes.html new file mode 100644 index 000000000..ace3cf6f1 --- /dev/null +++ b/files/templates/notification_mutes.html @@ -0,0 +1,29 @@ +{% extends "default.html" %} +{% block pagetitle %}Notification Mutes{% endblock %} +{% block content %} +
Notification Mutes
+
+ + + + + + + +{% for mute in mutes %} + + + + + +{% endfor %} +
UserTargetMuted on
+ {% with user = mute.user %} + {% include "user_in_table.html" %} + {% endwith %} + + {% with user = mute.target %} + {% include "user_in_table.html" %} + {% endwith %} +
+{% endblock %}