forked from rDrama/rDrama
master
parent
37bbd80ede
commit
9c030fb1a5
|
@ -26,6 +26,7 @@ IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||||
@app.post("/@<username>/revert_actions")
|
@app.post("/@<username>/revert_actions")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def revert_actions(v, username):
|
def revert_actions(v, username):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
|
|
||||||
|
@ -42,9 +43,11 @@ def revert_actions(v, username):
|
||||||
|
|
||||||
return {"message": "Admin actions reverted!"}
|
return {"message": "Admin actions reverted!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/make_admin")
|
@app.post("/@<username>/make_admin")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def make_admin(v, username):
|
def make_admin(v, username):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 6
|
user.admin_level = 6
|
||||||
|
@ -52,9 +55,21 @@ def make_admin(v, username):
|
||||||
return {"message": "User has been made admin!"}
|
return {"message": "User has been made admin!"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/@<username>/remove_admin")
|
||||||
|
@admin_level_required(6)
|
||||||
|
def remove_admin(v, username):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
|
user = get_user(username)
|
||||||
|
if not user: abort(404)
|
||||||
|
user.admin_level = 0
|
||||||
|
g.db.add(user)
|
||||||
|
return {"message": "Admin removed!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/make_fake_admin")
|
@app.post("/@<username>/make_fake_admin")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def make_fake_admin(v, username):
|
def make_fake_admin(v, username):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 1
|
user.admin_level = 1
|
||||||
|
@ -62,14 +77,68 @@ def make_fake_admin(v, username):
|
||||||
return {"message": "User has been made fake admin!"}
|
return {"message": "User has been made fake admin!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/remove_admin")
|
@app.post("/@<username>/remove_fake_admin")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def remove_admin(v, username):
|
def remove_fake_admin(v, username):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 0
|
user.admin_level = 0
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
return {"message": "Admin removed!"}
|
return {"message": "Fake admin removed!"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/admin/monthly")
|
||||||
|
@limiter.limit("1/day")
|
||||||
|
@admin_level_required(6)
|
||||||
|
def monthly(v):
|
||||||
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
||||||
|
_awards = []
|
||||||
|
for u in g.db.query(User).filter(User.patron > 0).all():
|
||||||
|
grant_awards = {}
|
||||||
|
|
||||||
|
if u.patron == 1:
|
||||||
|
grant_awards["shit"] = 1
|
||||||
|
grant_awards["stars"] = 1
|
||||||
|
elif u.patron == 2:
|
||||||
|
grant_awards["shit"] = 3
|
||||||
|
grant_awards["stars"] = 3
|
||||||
|
elif u.patron == 3:
|
||||||
|
grant_awards["shit"] = 5
|
||||||
|
grant_awards["stars"] = 5
|
||||||
|
grant_awards["ban"] = 1
|
||||||
|
elif u.patron == 4:
|
||||||
|
grant_awards["shit"] = 10
|
||||||
|
grant_awards["stars"] = 10
|
||||||
|
grant_awards["ban"] = 3
|
||||||
|
elif u.patron == 5 or u.patron == 8:
|
||||||
|
grant_awards["shit"] = 20
|
||||||
|
grant_awards["stars"] = 20
|
||||||
|
grant_awards["ban"] = 6
|
||||||
|
|
||||||
|
|
||||||
|
for name in grant_awards:
|
||||||
|
for count in range(grant_awards[name]):
|
||||||
|
|
||||||
|
thing += 1
|
||||||
|
|
||||||
|
_awards.append(AwardRelationship(
|
||||||
|
id=thing,
|
||||||
|
user_id=u.id,
|
||||||
|
kind=name
|
||||||
|
))
|
||||||
|
|
||||||
|
text = "You were given the following awards:\n\n"
|
||||||
|
|
||||||
|
for key, value in grant_awards.items():
|
||||||
|
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
||||||
|
|
||||||
|
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
|
||||||
|
|
||||||
|
g.db.bulk_save_objects(_awards)
|
||||||
|
|
||||||
|
return {"message": "Monthly awards granted"}
|
||||||
|
|
||||||
|
|
||||||
@app.get('/admin/rules')
|
@app.get('/admin/rules')
|
||||||
|
@ -188,59 +257,6 @@ def admin_home(v):
|
||||||
x = f.read()
|
x = f.read()
|
||||||
return render_template("admin/admin_home.html", v=v, x=x)
|
return render_template("admin/admin_home.html", v=v, x=x)
|
||||||
|
|
||||||
@app.post("/admin/monthly")
|
|
||||||
@limiter.limit("1/day")
|
|
||||||
@admin_level_required(6)
|
|
||||||
def monthly(v):
|
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
|
||||||
_awards = []
|
|
||||||
for u in g.db.query(User).filter(User.patron > 0).all():
|
|
||||||
grant_awards = {}
|
|
||||||
|
|
||||||
if u.patron == 1:
|
|
||||||
grant_awards["shit"] = 1
|
|
||||||
grant_awards["stars"] = 1
|
|
||||||
elif u.patron == 2:
|
|
||||||
grant_awards["shit"] = 3
|
|
||||||
grant_awards["stars"] = 3
|
|
||||||
elif u.patron == 3:
|
|
||||||
grant_awards["shit"] = 5
|
|
||||||
grant_awards["stars"] = 5
|
|
||||||
grant_awards["ban"] = 1
|
|
||||||
elif u.patron == 4:
|
|
||||||
grant_awards["shit"] = 10
|
|
||||||
grant_awards["stars"] = 10
|
|
||||||
grant_awards["ban"] = 3
|
|
||||||
elif u.patron == 5 or u.patron == 8:
|
|
||||||
grant_awards["shit"] = 20
|
|
||||||
grant_awards["stars"] = 20
|
|
||||||
grant_awards["ban"] = 6
|
|
||||||
|
|
||||||
|
|
||||||
for name in grant_awards:
|
|
||||||
for count in range(grant_awards[name]):
|
|
||||||
|
|
||||||
thing += 1
|
|
||||||
|
|
||||||
_awards.append(AwardRelationship(
|
|
||||||
id=thing,
|
|
||||||
user_id=u.id,
|
|
||||||
kind=name
|
|
||||||
))
|
|
||||||
|
|
||||||
text = "You were given the following awards:\n\n"
|
|
||||||
|
|
||||||
for key, value in grant_awards.items():
|
|
||||||
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
|
||||||
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
|
|
||||||
|
|
||||||
g.db.bulk_save_objects(_awards)
|
|
||||||
|
|
||||||
|
|
||||||
return {"message": "Monthly awards granted"}
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/admin/disablesignups")
|
@app.post("/admin/disablesignups")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
{% if v.id in [1,28,29,995] %}
|
{% if v.id in [1,12,28,29,747,995] %}
|
||||||
<div><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/admin/monthly')">Grant Monthly Awards</a></div>
|
<div><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/admin/monthly')">Grant Monthly Awards</a></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -201,7 +201,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'rdrama' in request.host and v.id in [28,29,995] %}
|
{% if 'rdrama' in request.host and v.id in [12,28,29,747,995] %}
|
||||||
{% if u.admin_level == 0 %}
|
{% if u.admin_level == 0 %}
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
|
||||||
|
@ -468,7 +468,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'rdrama' in request.host and v.id in [28,29,995] %}
|
{% if 'rdrama' in request.host and v.id in [12,28,29,747,995] %}
|
||||||
{% if u.admin_level == 0 %}
|
{% if u.admin_level == 0 %}
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
|
||||||
|
|
Loading…
Reference in New Issue