forked from MarseyWorld/MarseyWorld
vcxvcx
parent
3c321b908e
commit
cb5c37cc77
|
@ -3,8 +3,6 @@ video.mp4
|
|||
video.webm
|
||||
cache/
|
||||
__pycache__/
|
||||
disable_signups
|
||||
under_attack
|
||||
.idea/
|
||||
**/.pytest_cache/
|
||||
venv/
|
||||
|
|
|
@ -342,20 +342,13 @@ def reported_comments(v):
|
|||
@app.get("/admin")
|
||||
@admin_level_required(2)
|
||||
def admin_home(v):
|
||||
|
||||
with open('disable_signups', 'r') as f: x = f.read()
|
||||
with open('under_attack', 'r') as f: x2 = f.read()
|
||||
|
||||
return render_template("admin/admin_home.html", v=v, x=x, x2=x2)
|
||||
return render_template("admin/admin_home.html", v=v)
|
||||
|
||||
@app.post("/admin/disable_signups")
|
||||
@admin_level_required(3)
|
||||
def disable_signups(v):
|
||||
with open('disable_signups', 'r') as f: content = f.read()
|
||||
|
||||
with open('disable_signups', 'w') as f:
|
||||
if content == "yes":
|
||||
f.write("no")
|
||||
if environ.get('disable_signups'):
|
||||
environ["disable_signups"] = ""
|
||||
ma = ModAction(
|
||||
kind="enable_signups",
|
||||
user_id=v.id,
|
||||
|
@ -364,7 +357,7 @@ def disable_signups(v):
|
|||
g.db.commit()
|
||||
return {"message": "Signups enabled!"}
|
||||
else:
|
||||
f.write("yes")
|
||||
environ["disable_signups"] = "1"
|
||||
ma = ModAction(
|
||||
kind="disable_signups",
|
||||
user_id=v.id,
|
||||
|
@ -386,11 +379,8 @@ def purge_cache(v):
|
|||
@app.post("/admin/under_attack")
|
||||
@admin_level_required(2)
|
||||
def under_attack(v):
|
||||
with open('under_attack', 'r') as f: content = f.read()
|
||||
|
||||
with open('under_attack', 'w') as f:
|
||||
if content == "yes":
|
||||
f.write("no")
|
||||
if environ.get('under_attack'):
|
||||
environ["under_attack"] = ""
|
||||
ma = ModAction(
|
||||
kind="disable_under_attack",
|
||||
user_id=v.id,
|
||||
|
@ -402,7 +392,7 @@ def under_attack(v):
|
|||
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
|
||||
return {"error": "Failed to disable under attack mode."}
|
||||
else:
|
||||
f.write("yes")
|
||||
environ["under_attack"] = "1"
|
||||
ma = ModAction(
|
||||
kind="enable_under_attack",
|
||||
user_id=v.id,
|
||||
|
|
|
@ -170,8 +170,8 @@ def logout(v):
|
|||
@app.get("/signup")
|
||||
@auth_desired
|
||||
def sign_up_get(v):
|
||||
with open('disable_signups', 'r') as f:
|
||||
if f.read() == "yes": return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||
if environ.get('disable_signups'):
|
||||
return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||
|
||||
if v: return redirect(f"{SITE_FULL}/")
|
||||
|
||||
|
@ -214,8 +214,8 @@ def sign_up_get(v):
|
|||
@limiter.limit("1/minute;5/day")
|
||||
@auth_desired
|
||||
def sign_up_post(v):
|
||||
with open('disable_signups', 'r') as f:
|
||||
if f.read() == "yes": return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||
if environ.get('disable_signups'):
|
||||
return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||
|
||||
if v: abort(403)
|
||||
|
||||
|
|
|
@ -59,14 +59,14 @@
|
|||
|
||||
{% if v.admin_level > 2 %}
|
||||
<div class="custom-control custom-switch">
|
||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="disable_signups" name="disable_signups" {% if x == "yes" %}checked{% endif %} onchange="post_toast('/admin/disable_signups');">
|
||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="disable_signups" name="disable_signups" {% if environ.get('disable_signups') %}checked{% endif %} onchange="post_toast('/admin/disable_signups');">
|
||||
<label class="custom-control-label" for="disable_signups">Disable signups</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if v.admin_level == 3 %}
|
||||
<div class="custom-control custom-switch mt-3">
|
||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="under_attack" name="under_attack" {% if x2 == "yes" %}checked{% endif %} onchange="post_toast('/admin/under_attack');">
|
||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="under_attack" name="under_attack" {% if environ.get('under_attack') %}checked{% endif %} onchange="post_toast('/admin/under_attack');">
|
||||
<label class="custom-control-label" for="under_attack">Under attack mode</label>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -288,11 +288,9 @@
|
|||
|
||||
|
||||
{% if v.id != p.author_id and not p.ghost %}
|
||||
<a id="unblock-{{p.id}}" class="text-success list-inline-item {% if not p.is_blocking %} d-none{% endif %}" role="button" onclick="post_toast2('/settings/unblock?username={{p.author_name}}','block-{{p.id}}','unblock-{{p.id}}')"><i class="fas fa-eye text-success"></i>Unblock user</a>
|
||||
<a id="unblock-{{p.id}}" class="dropdown-item text-success list-inline-item {% if not p.is_blocking %}d-none{% endif %}" role="button" onclick="post_toast2('/settings/unblock?username={{p.author_name}}','block-{{p.id}}','unblock-{{p.id}}')"><i class="fas fa-eye text-success"></i>Unblock user</a>
|
||||
|
||||
<a id="prompt-{{p.id}}" class="dropdown-item text-danger blockuser list-inline-item d-none" role="button" onclick="post_toast2('/settings/block?username={{p.author_name}}','prompt-{{p.id}}','unblock-{{p.id}}')"><i class="fas fa-eye-slash text-danger"></i>Are you sure?</a>
|
||||
|
||||
<a id="block-{{p.id}}" class="dropdown-item text-danger blockuser list-inline-item {% if p.is_blocking %} d-none{% endif %}" role="button" onclick="document.getElementById('block-{{p.id}}').classList.toggle('d-none');document.getElementById('prompt-{{p.id}}').classList.toggle('d-none');"><i class="fas fa-eye-slash text-danger"></i>Block user</a>
|
||||
<a id="block-{{p.id}}" class="dropdown-item list-inline-item text-danger {% if p.is_blocking %}d-none{% endif %}" role="button" onclick="post_toast2('/settings/block?username={{p.author_name}}','block-{{p.id}}','unblock-{{p.id}}')"><i class="fas fa-eye-slash text-danger"></i>Block user</a>
|
||||
{% endif %}
|
||||
|
||||
{% if v.id==p.author_id or v.admin_level > 1 %}
|
||||
|
|
Loading…
Reference in New Issue