got rid of printi awards

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-05 23:23:00 +02:00
parent f77bab96eb
commit 3cd21e8899
3 changed files with 1 additions and 152 deletions

View File

@ -435,84 +435,3 @@ def award_thing(v, thing_type, id):
if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
return redirect(SITE_FULL)
@app.get("/admin/awards")
@admin_level_required(2)
def admin_userawards_get(v):
if not FEATURES['AWARDS']:
abort(404)
if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
if v.admin_level != 3:
return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
@app.post("/admin/awards")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
def admin_userawards_post(v):
if not FEATURES['AWARDS']:
abort(404)
if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
if SITE == 'watchpeopledie.co' and v.id not in (AEVANN_ID, CARP_ID, SNAKES_ID): abort(403)
try: u = request.values.get("username").strip()
except: abort(404)
whitelist = ("shit", "fireflies", "train", "scooter", "wholesome", "tilt", "glowie")
u = get_user(u, v=v)
notify_awards = {}
for key, value in request.values.items():
if key not in AWARDS: continue
if v.admin_level < 3 and key not in whitelist: continue
if value:
if int(value) > 10: abort(403)
if int(value): notify_awards[key] = int(value)
for x in range(int(value)):
award = AwardRelationship(
user_id=u.id,
kind=key,
granted_by=v.id
)
g.db.add(award)
if v.id != u.id:
text = f"@{v.username} has given you the following awards:\n\n"
for key, value in notify_awards.items():
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
send_repeatable_notification(u.id, text)
note = ""
for key, value in notify_awards.items():
note += f"{value} {AWARDS[key]['title']}, "
if len(note) > 500: return {"error": "You're giving too many awards at the same time!"}, 400
ma=ModAction(
kind="grant_awards",
user_id=v.id,
target_user_id=u.id,
_note=note[:-2]
)
g.db.add(ma)
if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")

View File

@ -65,9 +65,6 @@
{% if FEATURES['BADGES'] or FEATURES['AWARDS'] -%}
<h4>Grant</h4>
<ul>
{% if FEATURES['AWARDS'] -%}
<li><a href="/admin/awards">Give User Award</a></li>
{%- endif %}
{% if FEATURES['BADGES'] -%}
<li><a href="/admin/badge_grant">Grant Badges</a></li>
<li><a href="/admin/badge_remove">Remove Badges</a></li>
@ -140,4 +137,4 @@
Live Revision: <code>{{ gitref }}</code> <br>
</div>
{% endblock %}
{% endblock %}

View File

@ -1,67 +0,0 @@
{% extends "default.html" %}
{% block title %}
<title>Grant User Award</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 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 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>User Award Grant</h5>
<form action="/admin/awards", method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<label for="input-username">Username</label><br>
<input autocomplete="off" id="input-username" class="form-control mb-3" 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">Icon</th>
<th scope="col">Title</th>
<th scope="col">Amount</th>
</tr>
</thead>
<tbody>
{% for a in awards %}
<tr>
<td><i class="{{a['icon']}} {{a['color']}}" style="font-size: 30px"></i></td>
<td>{{a['title']}}</td>
<td><input autocomplete="off" type="number" class="form-control" name="{{a['kind']}}" min="0" max="10" placeholder="Enter number..."></td>
</tr>
{% endfor %}
</table>
<input autocomplete="off" class="btn btn-primary mt-3" type="submit" onclick="disable(this)" value="Grant Awards">
</form>
<pre></pre>
{% endblock %}