add "offline mode"
parent
312abdee28
commit
33464589aa
|
@ -504,6 +504,7 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
'IGNORE_BADGE_BLACKLIST': 5,
|
'IGNORE_BADGE_BLACKLIST': 5,
|
||||||
'ENABLE_DM_IMAGES': 5,
|
'ENABLE_DM_IMAGES': 5,
|
||||||
'SEE_GHOST_VOTES': 5,
|
'SEE_GHOST_VOTES': 5,
|
||||||
|
'SITE_OFFLINE_MODE': 5,
|
||||||
|
|
||||||
'MODS_EVERY_HOLE': 6,
|
'MODS_EVERY_HOLE': 6,
|
||||||
'MODS_EVERY_GROUP': 6,
|
'MODS_EVERY_GROUP': 6,
|
||||||
|
|
|
@ -66,6 +66,11 @@ MODACTION_TYPES = {
|
||||||
"icon": 'fa-gas-pump-slash',
|
"icon": 'fa-gas-pump-slash',
|
||||||
"color": 'bg-danger'
|
"color": 'bg-danger'
|
||||||
},
|
},
|
||||||
|
'disable_offline_mode': {
|
||||||
|
"str": 'disabled offline mode',
|
||||||
|
"icon": 'fa-lock-open',
|
||||||
|
"color": 'bg-success'
|
||||||
|
},
|
||||||
'disable_read_only_mode': {
|
'disable_read_only_mode': {
|
||||||
"str": 'disabled read only mode',
|
"str": 'disabled read only mode',
|
||||||
"icon": 'fa-book',
|
"icon": 'fa-book',
|
||||||
|
@ -136,6 +141,11 @@ MODACTION_TYPES = {
|
||||||
"icon": 'fa-gas-pump',
|
"icon": 'fa-gas-pump',
|
||||||
"color": 'bg-success'
|
"color": 'bg-success'
|
||||||
},
|
},
|
||||||
|
'enable_offline_mode': {
|
||||||
|
"str": 'enabled offline mode',
|
||||||
|
"icon": 'fa-lock',
|
||||||
|
"color": 'bg-danger'
|
||||||
|
},
|
||||||
'enable_read_only_mode': {
|
'enable_read_only_mode': {
|
||||||
"str": 'enabled read only mode',
|
"str": 'enabled read only mode',
|
||||||
"icon": 'fa-book',
|
"icon": 'fa-book',
|
||||||
|
|
|
@ -10,6 +10,7 @@ _SETTINGS = {
|
||||||
"bots": True,
|
"bots": True,
|
||||||
"fart_mode": False,
|
"fart_mode": False,
|
||||||
"read_only_mode": False,
|
"read_only_mode": False,
|
||||||
|
"offline_mode": False,
|
||||||
"signups": True,
|
"signups": True,
|
||||||
"login_required": False,
|
"login_required": False,
|
||||||
"under_siege": False,
|
"under_siege": False,
|
||||||
|
|
|
@ -376,6 +376,10 @@ def change_settings(v:User, setting):
|
||||||
|
|
||||||
if setting not in get_settings().keys():
|
if setting not in get_settings().keys():
|
||||||
abort(404, f"Setting '{setting}' not found")
|
abort(404, f"Setting '{setting}' not found")
|
||||||
|
|
||||||
|
if setting == "offline_mode" and v.admin_level < PERMS["SITE_OFFLINE_MODE"]:
|
||||||
|
abort(403, "You can't change this setting!")
|
||||||
|
|
||||||
val = toggle_setting(setting)
|
val = toggle_setting(setting)
|
||||||
if val: word = 'enable'
|
if val: word = 'enable'
|
||||||
else: word = 'disable'
|
else: word = 'disable'
|
||||||
|
|
|
@ -55,7 +55,10 @@ def get_logged_in_user():
|
||||||
session.pop("lo_user")
|
session.pop("lo_user")
|
||||||
|
|
||||||
if request.method.lower() != "get" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['SITE_BYPASS_READ_ONLY_MODE']):
|
if request.method.lower() != "get" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['SITE_BYPASS_READ_ONLY_MODE']):
|
||||||
abort(403)
|
abort(403, "Site is in read-only mode right now. It will be back shortly!")
|
||||||
|
|
||||||
|
if get_setting('offline_mode') and not (v and v.admin_level >= PERMS['SITE_OFFLINE_MODE']):
|
||||||
|
abort(403, "Site is in offline mode right now. It will be back shortly!")
|
||||||
|
|
||||||
g.v = v
|
g.v = v
|
||||||
|
|
||||||
|
|
|
@ -120,10 +120,12 @@
|
||||||
|
|
||||||
{% if v.admin_level >= PERMS['SITE_SETTINGS'] %}
|
{% if v.admin_level >= PERMS['SITE_SETTINGS'] %}
|
||||||
{% for setting in SITE_SETTINGS.keys() %}
|
{% for setting in SITE_SETTINGS.keys() %}
|
||||||
<div class="custom-control custom-switch{% if loop.index > 1 %} mt-1{% endif %}" id="settings-{{setting}}-container">
|
{% if not (setting == "offline_mode" and v.admin_level < PERMS["SITE_OFFLINE_MODE"]) %}
|
||||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="settings-{{setting}}-checkbox" {% if SITE_SETTINGS[setting] %}checked{% endif %} data-nonce="{{g.nonce}}" data-onchange="postToastSwitch(this, '/admin/site_settings/{{setting}}');">
|
<div class="custom-control custom-switch{% if loop.index > 1 %} mt-1{% endif %}" id="settings-{{setting}}-container">
|
||||||
<label class="custom-control-label" for="settings-{{setting}}-checkbox">{{setting.replace('_', ' ').title()}}</label>
|
<input autocomplete="off" type="checkbox" class="custom-control-input" id="settings-{{setting}}-checkbox" {% if SITE_SETTINGS[setting] %}checked{% endif %} data-nonce="{{g.nonce}}" data-onchange="postToastSwitch(this, '/admin/site_settings/{{setting}}');">
|
||||||
</div>
|
<label class="custom-control-label" for="settings-{{setting}}-checkbox">{{setting.replace('_', ' ').title()}}</label>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue