30->5 min wait on cleanup. Strip errors.

Small formatting tweaks in writing.html
This commit is contained in:
Sage Vaillancourt 2021-07-28 19:21:02 -04:00
parent e10f876214
commit b591532ae8
3 changed files with 12 additions and 9 deletions

View File

@ -28,6 +28,7 @@
if (document.getElementById('company').value === "BananaCorp") {
return
}
cookies = [
'username',
'company',
@ -62,6 +63,7 @@
{{ render_field(form.body, 'class=bigtext') }}
{{ render_field(form.closingtext) }}
</dl>
{% if errors %}
<div id=errors>
<h3>Your letter has errors.</h3>
@ -77,9 +79,10 @@
</p>
</div>
{% endif %}
<p><input type=submit value="Submit"
{% if errors %}
onclick="var elem = document.getElementById('errors'); elem.parentNode.removeChild(elem);"
onclick="var e = document.getElementById('errors'); e.parentNode.removeChild(e);"
{% endif %}
></p>
</form>

View File

@ -62,7 +62,7 @@ class CLData():
if result.returncode == 0:
print(build_text + "[SUCCESS]")
threading.Timer(60 * 30, cleanup, [output_dir + unique_id]).start()
threading.Timer(60 * 5, cleanup, [output_dir + unique_id]).start()
return (send_from_directory(
output_dir,
@ -73,7 +73,7 @@ class CLData():
else:
print(build_text + "[FAIL]")
# Collect output but delete boilerplate text
errors = result.stdout.split("\n")
errors = list(map(str.strip, result.stdout.split("\n")))
del errors[:13]
del errors[-2:]
return (None, errors)

View File

@ -62,12 +62,12 @@ def index():
)
(resp, errors) = data.generate_pdf()
# Save entered data as cookies on user's machine
if errors:
resp = make_response(render_template('writing.html',
form=form,
errors=errors,
))
# Save entered data as cookies on user's machine
for pair in data.get_pairs():
resp.set_cookie(pair[0], urllib.parse.quote(pair[1]))
return resp