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 @@