From 4a7373f7bf0687d67106caf439d836c3ea7cb6a4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 11 Jan 2022 05:28:35 +0200 Subject: [PATCH] bb --- files/routes/admin.py | 32 +++++++++ files/routes/posts.py | 2 +- files/templates/admin/admin_home.html | 3 +- files/templates/admin/badge_remove.html | 89 +++++++++++++++++++++++++ files/templates/award_modal.html | 2 +- files/templates/emoji_modal.html | 2 +- 6 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 files/templates/admin/badge_remove.html diff --git a/files/routes/admin.py b/files/routes/admin.py index 3ab6867de..074136a9d 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -460,6 +460,38 @@ def badge_grant_post(v): return render_template(f"{template}admin/badge_grant.html", v=v, badge_types=BADGES, msg="Badge granted!") + +@app.get("/admin/badge_remove") +@admin_level_required(2) +def badge_remove_get(v): + if not v or v.oldsite: template = '' + else: template = 'CHRISTMAS/' + + return render_template(f"{template}admin/badge_remove.html", v=v, badge_types=BADGES) + + +@app.post("/admin/badge_remove") +@limiter.limit("1/second") +@admin_level_required(2) +def badge_remove_post(v): + if not v or v.oldsite: template = '' + else: template = 'CHRISTMAS/' + + user = get_user(request.values.get("username").strip(), graceful=True) + if not user: + return render_template(f"{template}admin/badge_remove.html", v=v, badge_types=BADGES, error="User not found.") + + try: badge_id = int(request.values.get("badge_id")) + except: abort(400) + + badge = user.has_badge(badge_id) + if badge: + g.db.delete(badge) + g.db.commit() + + return render_template(f"{template}admin/badge_remove.html", v=v, badge_types=BADGES, msg="Badge removed!") + + @app.get("/admin/users") @admin_level_required(2) def users_list(v): diff --git a/files/routes/posts.py b/files/routes/posts.py index 54fab4e6f..955f61738 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -201,7 +201,7 @@ def post_id(pid, anything=None, v=None): offset = 0 - if not request.headers.get("Authorization") and post.comment_count > 60 and not (v and v.id == 1): + if not request.headers.get("Authorization") and post.comment_count > 60: comments2 = [] count = 0 if post.created_utc > 1638672040: diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index 0c1f338a2..2092570bc 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -37,7 +37,8 @@

Grant

API Access Control

diff --git a/files/templates/admin/badge_remove.html b/files/templates/admin/badge_remove.html new file mode 100644 index 000000000..3a32758d2 --- /dev/null +++ b/files/templates/admin/badge_remove.html @@ -0,0 +1,89 @@ +{% extends "default.html" %} + +{% block title %} +Badge Remove +{% endblock %} + +{% block pagetype %}message{% endblock %} + +{% block content %} + + {% if error %} + + {% endif %} + {% if msg %} + + {% endif %} + +

+

+
Badge Remove
+ +
+ + + +
+ + +
+ + + + + + + + + +{% for k, v in badge_types.items() %} + + + + + + +{% endfor %} +
SelectImageNameDefault Description
+
+ + +
+
{{v['name']}}{{v['description']}}
+ +
+ + +
+ + + + + + + + +{% endblock %} diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 72d72985c..b6091c700 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -1,4 +1,4 @@ - +