mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 23:10:36 +01:00
Accueil restructuré (zones Discord/Twitch, stats, indicateur connexion) + Top 3 sanctions/modérateurs + BOT_STATUS dans config Flask
This commit is contained in:
@@ -3,16 +3,58 @@ from webapp import webapp
|
||||
from database import db
|
||||
from database.models import ModerationEvent
|
||||
|
||||
def _top_sanctioned():
|
||||
return (
|
||||
db.session.query(
|
||||
ModerationEvent.discord_id,
|
||||
db.func.max(ModerationEvent.username).label("username"),
|
||||
db.func.count(ModerationEvent.id).label("count"),
|
||||
)
|
||||
.group_by(ModerationEvent.discord_id)
|
||||
.order_by(db.func.count(ModerationEvent.id).desc())
|
||||
.limit(3)
|
||||
.all()
|
||||
)
|
||||
|
||||
def _top_moderators():
|
||||
return (
|
||||
db.session.query(
|
||||
ModerationEvent.staff_id,
|
||||
db.func.max(ModerationEvent.staff_name).label("staff_name"),
|
||||
db.func.count(ModerationEvent.id).label("count"),
|
||||
)
|
||||
.group_by(ModerationEvent.staff_id)
|
||||
.order_by(db.func.count(ModerationEvent.id).desc())
|
||||
.limit(3)
|
||||
.all()
|
||||
)
|
||||
|
||||
@webapp.route("/moderation")
|
||||
def moderation():
|
||||
events = ModerationEvent.query.order_by(ModerationEvent.created_at.desc()).all()
|
||||
return render_template("moderation.html", events=events, event=None)
|
||||
top_sanctioned = _top_sanctioned()
|
||||
top_moderators = _top_moderators()
|
||||
return render_template(
|
||||
"moderation.html",
|
||||
events=events,
|
||||
event=None,
|
||||
top_sanctioned=top_sanctioned,
|
||||
top_moderators=top_moderators,
|
||||
)
|
||||
|
||||
@webapp.route("/moderation/edit/<int:event_id>")
|
||||
def open_edit_moderation_event(event_id):
|
||||
event = ModerationEvent.query.get_or_404(event_id)
|
||||
events = ModerationEvent.query.order_by(ModerationEvent.created_at.desc()).all()
|
||||
return render_template("moderation.html", events=events, event=event)
|
||||
top_sanctioned = _top_sanctioned()
|
||||
top_moderators = _top_moderators()
|
||||
return render_template(
|
||||
"moderation.html",
|
||||
events=events,
|
||||
event=event,
|
||||
top_sanctioned=top_sanctioned,
|
||||
top_moderators=top_moderators,
|
||||
)
|
||||
|
||||
@webapp.route("/moderation/update/<int:event_id>", methods=['POST'])
|
||||
def update_moderation_event(event_id):
|
||||
|
||||
Reference in New Issue
Block a user