forked from MarseyWorld/MarseyWorld
vcxvcx
parent
3c321b908e
commit
cb5c37cc77
|
@ -3,8 +3,6 @@ video.mp4
|
||||||
video.webm
|
video.webm
|
||||||
cache/
|
cache/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
disable_signups
|
|
||||||
under_attack
|
|
||||||
.idea/
|
.idea/
|
||||||
**/.pytest_cache/
|
**/.pytest_cache/
|
||||||
venv/
|
venv/
|
||||||
|
|
|
@ -342,20 +342,13 @@ def reported_comments(v):
|
||||||
@app.get("/admin")
|
@app.get("/admin")
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
def admin_home(v):
|
def admin_home(v):
|
||||||
|
return render_template("admin/admin_home.html", v=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)
|
|
||||||
|
|
||||||
@app.post("/admin/disable_signups")
|
@app.post("/admin/disable_signups")
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def disable_signups(v):
|
def disable_signups(v):
|
||||||
with open('disable_signups', 'r') as f: content = f.read()
|
if environ.get('disable_signups'):
|
||||||
|
environ["disable_signups"] = ""
|
||||||
with open('disable_signups', 'w') as f:
|
|
||||||
if content == "yes":
|
|
||||||
f.write("no")
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="enable_signups",
|
kind="enable_signups",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
@ -364,7 +357,7 @@ def disable_signups(v):
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Signups enabled!"}
|
return {"message": "Signups enabled!"}
|
||||||
else:
|
else:
|
||||||
f.write("yes")
|
environ["disable_signups"] = "1"
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="disable_signups",
|
kind="disable_signups",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
@ -386,11 +379,8 @@ def purge_cache(v):
|
||||||
@app.post("/admin/under_attack")
|
@app.post("/admin/under_attack")
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
def under_attack(v):
|
def under_attack(v):
|
||||||
with open('under_attack', 'r') as f: content = f.read()
|
if environ.get('under_attack'):
|
||||||
|
environ["under_attack"] = ""
|
||||||
with open('under_attack', 'w') as f:
|
|
||||||
if content == "yes":
|
|
||||||
f.write("no")
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="disable_under_attack",
|
kind="disable_under_attack",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
@ -402,7 +392,7 @@ def under_attack(v):
|
||||||
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
|
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
|
||||||
return {"error": "Failed to disable under attack mode."}
|
return {"error": "Failed to disable under attack mode."}
|
||||||
else:
|
else:
|
||||||
f.write("yes")
|
environ["under_attack"] = "1"
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="enable_under_attack",
|
kind="enable_under_attack",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
|
|
@ -170,8 +170,8 @@ def logout(v):
|
||||||
@app.get("/signup")
|
@app.get("/signup")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_get(v):
|
def sign_up_get(v):
|
||||||
with open('disable_signups', 'r') as f:
|
if environ.get('disable_signups'):
|
||||||
if f.read() == "yes": return {"error": "New account registration is currently closed. Please come back later."}, 403
|
return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||||
|
|
||||||
if v: return redirect(f"{SITE_FULL}/")
|
if v: return redirect(f"{SITE_FULL}/")
|
||||||
|
|
||||||
|
@ -214,8 +214,8 @@ def sign_up_get(v):
|
||||||
@limiter.limit("1/minute;5/day")
|
@limiter.limit("1/minute;5/day")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_post(v):
|
def sign_up_post(v):
|
||||||
with open('disable_signups', 'r') as f:
|
if environ.get('disable_signups'):
|
||||||
if f.read() == "yes": return {"error": "New account registration is currently closed. Please come back later."}, 403
|
return {"error": "New account registration is currently closed. Please come back later."}, 403
|
||||||
|
|
||||||
if v: abort(403)
|
if v: abort(403)
|
||||||
|
|
||||||
|
|
|
@ -59,14 +59,14 @@
|
||||||
|
|
||||||
{% if v.admin_level > 2 %}
|
{% if v.admin_level > 2 %}
|
||||||
<div class="custom-control custom-switch">
|
<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>
|
<label class="custom-control-label" for="disable_signups">Disable signups</label>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v.admin_level == 3 %}
|
{% if v.admin_level == 3 %}
|
||||||
<div class="custom-control custom-switch mt-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>
|
<label class="custom-control-label" for="under_attack">Under attack mode</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -288,11 +288,9 @@
|
||||||
|
|
||||||
|
|
||||||
{% if v.id != p.author_id and not p.ghost %}
|
{% 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 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>
|
||||||
|
|
||||||
<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>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v.id==p.author_id or v.admin_level > 1 %}
|
{% if v.id==p.author_id or v.admin_level > 1 %}
|
||||||
|
|
Loading…
Reference in New Issue