forked from rDrama/rDrama
xvc
parent
f069ad9389
commit
92f1420e0f
|
@ -22,6 +22,40 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
|
||||||
|
|
||||||
month = datetime.now().strftime('%B')
|
month = datetime.now().strftime('%B')
|
||||||
|
|
||||||
|
if SITE_NAME == 'PCM':
|
||||||
|
@app.get('/admin/sidebar')
|
||||||
|
@admin_level_required(3)
|
||||||
|
def get_sidebar(v):
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||||
|
except:
|
||||||
|
sidebar = None
|
||||||
|
|
||||||
|
return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post('/admin/sidebar')
|
||||||
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
|
@admin_level_required(3)
|
||||||
|
def post_sidebar(v):
|
||||||
|
|
||||||
|
text = request.values.get('sidebar', '').strip()
|
||||||
|
|
||||||
|
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
|
||||||
|
|
||||||
|
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="change_sidebar",
|
||||||
|
user_id=v.id,
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
|
g.db.commit()
|
||||||
|
|
||||||
|
return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/make_admin")
|
@app.post("/@<username>/make_admin")
|
||||||
@limiter.limit("1/second;5/day")
|
@limiter.limit("1/second;5/day")
|
||||||
|
|
|
@ -862,7 +862,7 @@ def submit_post(v, sub=None):
|
||||||
|
|
||||||
sub = request.values.get("sub")
|
sub = request.values.get("sub")
|
||||||
|
|
||||||
if sub:
|
if sub and sub != 'none':
|
||||||
sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none()
|
sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none()
|
||||||
if not sub: abort(404)
|
if not sub: abort(404)
|
||||||
sub = sub[0]
|
sub = sub[0]
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{% extends "default.html" %}
|
||||||
|
|
||||||
|
{% block pagetitle %}Edit {{SITE_NAME}} sidebar{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% 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 %}
|
||||||
|
|
||||||
|
<div class="row my-5">
|
||||||
|
<div class="col col-md-8">
|
||||||
|
<div class="settings">
|
||||||
|
<div id="description">
|
||||||
|
<h2>Edit Sidebar</h2>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="body d-lg-flex">
|
||||||
|
<div class="w-lg-100">
|
||||||
|
<form id="profile-settings" action="/admin/sidebar" method="post">
|
||||||
|
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
|
<textarea autocomplete="off" maxlength="10000" class="form-control rounded" id="bio-text" aria-label="With textarea" placeholder="Enter sidebar here..." rows="50" name="sidebar" form="profile-settings">{% if sidebar %}{{sidebar}}{% endif %}</textarea>
|
||||||
|
|
||||||
|
<div class="d-flex mt-2">
|
||||||
|
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Save">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -88,6 +88,12 @@
|
||||||
{% set SUBS = toomuch_subs %}
|
{% set SUBS = toomuch_subs %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if SITE_NAME == 'PCM' %}
|
||||||
|
<option value="none" selected>
|
||||||
|
None
|
||||||
|
</option>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for s in SUBS %}
|
{% for s in SUBS %}
|
||||||
<option value="{{s}}" {% if sub and sub.name == s %}selected{% endif %}>
|
<option value="{{s}}" {% if sub and sub.name == s %}selected{% endif %}>
|
||||||
/s/{{s}}
|
/s/{{s}}
|
||||||
|
|
Loading…
Reference in New Issue