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 %}