Change add_letter error to a redirect
This commit is contained in:
parent
cd87e4fa29
commit
cca15686bf
|
@ -167,7 +167,7 @@ def add_letter() -> Response:
|
||||||
|
|
||||||
existing_letter_count = len(db.get_user_letters(user.id))
|
existing_letter_count = len(db.get_user_letters(user.id))
|
||||||
if user.in_free_tier() and existing_letter_count >= FREE_TIER_TEMPLATES:
|
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}'
|
new_letter_name = f'Letter{existing_letter_count + 1}'
|
||||||
default_form_json = jsonify(CLForm().to_cl_data()).get_data(True)
|
default_form_json = jsonify(CLForm().to_cl_data()).get_data(True)
|
||||||
db.add_letter(user.id, new_letter_name, default_form_json)
|
db.add_letter(user.id, new_letter_name, default_form_json)
|
||||||
|
@ -194,6 +194,9 @@ def index_get() -> Response:
|
||||||
|
|
||||||
form.letterName.data = 1
|
form.letterName.data = 1
|
||||||
selected_letter = request.args.get('letter_name')
|
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:
|
if selected_letter:
|
||||||
for i, letter in enumerate(letters):
|
for i, letter in enumerate(letters):
|
||||||
|
@ -216,7 +219,7 @@ def index_get() -> Response:
|
||||||
form.skillTypes.data = data['skillTypes']
|
form.skillTypes.data = data['skillTypes']
|
||||||
form.username.data = data['username']
|
form.username.data = data['username']
|
||||||
|
|
||||||
return render_index(form=form)
|
return render_index(form=form, error=error)
|
||||||
|
|
||||||
|
|
||||||
@writing_blueprint.route('/reset', methods=['POST', 'GET'])
|
@writing_blueprint.route('/reset', methods=['POST', 'GET'])
|
||||||
|
|
|
@ -59,7 +59,9 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="user logged-out">
|
<div class="user logged-out">
|
||||||
<form action="/create_account">
|
<form action="/create_account">
|
||||||
<div class="black-white-button" style="font-family: 'BarlowMedium'; margin-right: 1em; padding: 0.4em 1em;" onclick="showModal(false, 'Create your account')">Create account</div>
|
<div class="black-white-button" style="font-family: 'BarlowMedium'; margin-right: 1em; padding: 0.4em 1em;" onclick="showModal(false, 'Create your account')">
|
||||||
|
Create account
|
||||||
|
</div>
|
||||||
<div class="white-black-button" style="margin: 0; padding: 0.4em 1em;" onclick="showModal(true, 'Login now')">Log in</div>
|
<div class="white-black-button" style="margin: 0; padding: 0.4em 1em;" onclick="showModal(true, 'Login now')">Log in</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue