remotes/1693045480750635534/spooky-22
parent
b7a1c515e1
commit
4a7373f7bf
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
<h4>Grant</h4>
|
||||
<ul>
|
||||
<li><a href="/admin/awards">Give User Award</a></li>
|
||||
<li><a href="/admin/badge_grant">Badges</a></li>
|
||||
<li><a href="/admin/badge_grant">Grant Badges</a></li>
|
||||
<li><a href="/admin/badge_remove">Remove Badges</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>API Access Control</h4>
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>Badge Remove</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}message{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-exclamation-circle my-auto"></i>
|
||||
<span>
|
||||
{{error}}
|
||||
</span>
|
||||
<button role="button" class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if msg %}
|
||||
<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
|
||||
<span>
|
||||
{{msg}}
|
||||
</span>
|
||||
<button role="button" class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<pre></pre>
|
||||
<pre></pre>
|
||||
<h5>Badge Remove</h5>
|
||||
|
||||
<form action="/admin/badge_remove", method="post">
|
||||
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
|
||||
|
||||
<label for="input-username">Username</label><br>
|
||||
<input autocomplete="off" id="input-username" class="form-control" type="text" name="username" required>
|
||||
|
||||
<div class="overflow-x-auto"><table class="table table-striped">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th scope="col">Select</th>
|
||||
<th scope="col">Image</th>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Default Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for k, v in badge_types.items() %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="custom-control">
|
||||
<input autocomplete="off" checked="" class="custom-control-input" type="radio" id="{{k}}" name="badge_id" value="{{k}}">
|
||||
<label class="custom-control-label" for="{{k}}"></label>
|
||||
</div>
|
||||
</td>
|
||||
<td><label for="badge-{{k}}"><img alt="{{v['name']}}" loading="lazy" src="/static/assets/images/badges/{{v['name']}}.webp?a=3" width="70px" height="70px"></label></td>
|
||||
<td>{{v['name']}}</td>
|
||||
<td>{{v['description']}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<label for="input-url">URL</label><br>
|
||||
<input autocomplete="off" id="input-url" class="form-control" type="text" name="url" placeholder="Optional">
|
||||
|
||||
<label for="input-description">Custom description</label><br>
|
||||
<input autocomplete="off" id="input-description" class="form-control" type="text" name="description" placeholder="Leave blank for badge default">
|
||||
|
||||
<input autocomplete="off" class="btn btn-primary" type="submit">
|
||||
|
||||
</form>
|
||||
|
||||
<style>
|
||||
@media (max-width: 767.98px) {
|
||||
table {
|
||||
display: inline-block;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
|||
<script src="/static/assets/js/award_modal.js?a=3"></script>
|
||||
<script src="/static/assets/js/award_modal.js?a=4"></script>
|
||||
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered awardmodal" role="document">
|
||||
<div class="modal-content">
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/assets/js/emoji_modal.js?a=39"></script>
|
||||
<script src="/static/assets/js/emoji_modal.js?a=40"></script>
|
||||
|
||||
<style>
|
||||
a.emojitab {
|
||||
|
|
Loading…
Reference in New Issue