save failed css on failure

master
Aevann 2023-01-27 11:49:29 +02:00
parent 2c332c5fa7
commit 08bbe29726
2 changed files with 4 additions and 4 deletions

View File

@ -395,7 +395,7 @@ def kick(v:User, pid):
def sub_settings(v:User, sub):
sub = get_sub_by_name(sub)
if not v.mods(sub.name): abort(403)
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub)
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub, css=sub.css)
@app.post('/h/<sub>/sidebar')
@ -437,11 +437,11 @@ def post_sub_css(v:User, sub):
if len(css) > 6000:
error = "CSS is too long (max 6000 characters)"
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub, error=error)
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub, error=error, css=css)
valid, error = validate_css(css)
if not valid:
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub, error=error)
return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub, error=error, css=css)
sub.css = css
g.db.add(sub)

View File

@ -129,7 +129,7 @@
<div class="w-lg-100">
<form id="css" action="/h/{{sub}}/css" method="post">
<input hidden name="formkey" value="{{v|formkey}}">
<textarea autocomplete="off" maxlength="6000" class="form-control rounded" id="bio-text" placeholder="Enter css here..." rows="10" name="css" form="css">{% if sub.css %}{{sub.css}}{% endif %}</textarea>
<textarea autocomplete="off" maxlength="6000" class="form-control rounded" id="bio-text" placeholder="Enter css here..." rows="10" name="css" form="css">{% if css %}{{css}}{% endif %}</textarea>
<div class="d-flex mt-2">
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" value="Save">
</div>