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") { if (document.getElementById('company').value === "BananaCorp") {
return return
} }
cookies = [ cookies = [
'username', 'username',
'company', 'company',
@ -62,8 +63,9 @@
{{ render_field(form.body, 'class=bigtext') }} {{ render_field(form.body, 'class=bigtext') }}
{{ render_field(form.closingtext) }} {{ render_field(form.closingtext) }}
</dl> </dl>
{% if errors %} {% if errors %}
<div id=errors> <div id=errors>
<h3>Your letter has errors.</h3> <h3>Your letter has errors.</h3>
<p>There is likely a typo in one of your variables (the {\blabla} bits). <p>There is likely a typo in one of your variables (the {\blabla} bits).
@ -71,15 +73,16 @@
side</p> side</p>
<p class=errors> <p class=errors>
{% for error in errors %} {% for error in errors %}
{{ error }}<br> {{ error }}<br>
{% endfor %} {% endfor %}
</p> </p>
</div> </div>
{% endif %} {% endif %}
<p><input type=submit value="Submit" <p><input type=submit value="Submit"
{% if errors %} {% if errors %}
onclick="var elem = document.getElementById('errors'); elem.parentNode.removeChild(elem);" onclick="var e = document.getElementById('errors'); e.parentNode.removeChild(e);"
{% endif %} {% endif %}
></p> ></p>
</form> </form>

View File

@ -62,7 +62,7 @@ class CLData():
if result.returncode == 0: if result.returncode == 0:
print(build_text + "[SUCCESS]") 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( return (send_from_directory(
output_dir, output_dir,
@ -73,7 +73,7 @@ class CLData():
else: else:
print(build_text + "[FAIL]") print(build_text + "[FAIL]")
# Collect output but delete boilerplate text # 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[:13]
del errors[-2:] del errors[-2:]
return (None, errors) return (None, errors)

View File

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