diff --git a/flaskr/static/styles.css b/flaskr/static/styles.css index 8e545c9..dc15196 100644 --- a/flaskr/static/styles.css +++ b/flaskr/static/styles.css @@ -97,6 +97,10 @@ textarea { flex-grow: 1; } +.errors { + color: #a40f0f; +} + #body { flex-grow: 1; } diff --git a/flaskr/templates/writing.html b/flaskr/templates/writing.html index 4b79068..21e2f12 100644 --- a/flaskr/templates/writing.html +++ b/flaskr/templates/writing.html @@ -20,7 +20,11 @@ } return ""; } - function loadCookies() { + function init() { + {% if errors %} + window.scrollTo(0, document.body.scrollHeight); + {% endif %} + if (document.getElementById('company').value === "BananaCorp") { return } @@ -43,7 +47,7 @@ } } } - window.onload = loadCookies; + window.onload = init; @@ -61,14 +65,26 @@ {{ render_field(form.body, 'class=bigtext') }} {{ render_field(form.closingtext) }} - {% if err %} -

- {% for error in err %} - {{ error }}
- {% endfor %} + {% if errors %} +

+

Your letter has errors.

+ +

There is likely a typo in one of your variables (the {\blabla} bits). +
Make sure each is spelled correctly, and has the correct brackets on either + side

+ +

+ {% for error in errors %} + {{ error }}
+ {% endfor %}

+
{% endif %} -

+

diff --git a/writing.py b/writing.py index ac1fd44..c3e727d 100644 --- a/writing.py +++ b/writing.py @@ -61,12 +61,12 @@ def index(): body=form.body.data, ) - (resp, err) = data.generate_pdf() + (resp, errors) = data.generate_pdf() # Save entered data as cookies on user's machine - if err: + if errors: resp = make_response(render_template('writing.html', form=form, - err=err, + errors=errors, )) for pair in data.get_pairs(): resp.set_cookie(pair[0], urllib.parse.quote(pair[1]))