From cca15686bfde8d0cbb3050cefd8aff0a55737ea0 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 3 May 2023 20:09:12 +0000 Subject: [PATCH] Change add_letter error to a redirect --- app/routes.py | 7 +++++-- app/templates/base.jinja2 | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/routes.py b/app/routes.py index 09d173c..8c52319 100644 --- a/app/routes.py +++ b/app/routes.py @@ -167,7 +167,7 @@ def add_letter() -> Response: existing_letter_count = len(db.get_user_letters(user.id)) if user.in_free_tier() and existing_letter_count >= FREE_TIER_TEMPLATES: - return render_index(error=f'A maximum of {FREE_TIER_TEMPLATES} templates are available to each user.') + return redirect('/?error=template_limit') new_letter_name = f'Letter{existing_letter_count + 1}' default_form_json = jsonify(CLForm().to_cl_data()).get_data(True) db.add_letter(user.id, new_letter_name, default_form_json) @@ -194,6 +194,9 @@ def index_get() -> Response: form.letterName.data = 1 selected_letter = request.args.get('letter_name') + error = None + if request.args.get('error') == 'template_limit': + error = f'A maximum of {FREE_TIER_TEMPLATES} templates are available to each user.' if selected_letter: for i, letter in enumerate(letters): @@ -216,7 +219,7 @@ def index_get() -> Response: form.skillTypes.data = data['skillTypes'] form.username.data = data['username'] - return render_index(form=form) + return render_index(form=form, error=error) @writing_blueprint.route('/reset', methods=['POST', 'GET']) diff --git a/app/templates/base.jinja2 b/app/templates/base.jinja2 index ade3dcf..ea84868 100644 --- a/app/templates/base.jinja2 +++ b/app/templates/base.jinja2 @@ -59,7 +59,9 @@ {% else %}
-
Create account
+
+ Create account +
Log in