diff --git a/app.py b/app.py index 0950bbb..ec41d68 100644 --- a/app.py +++ b/app.py @@ -323,19 +323,19 @@ def request_form(): Rate limited to 5 submissions per minute per IP. """ if request.method == 'POST': - email = request.form.get('email', '').strip().lower() - if not is_valid_email(email): + form_data = { + 'name': request.form.get('name', '').strip(), + 'email': request.form.get('email', '').strip().lower(), + 'hobbies': request.form.get('hobbies', '').strip(), + 'notable_facts': request.form.get('notable_facts', '').strip(), + 'style_genre': request.form.get('style_genre', '').strip(), + 'extra_requests': request.form.get('extra_requests', '').strip(), + 'vocal_gender': request.form.get('vocal_gender', '').strip(), + } + if not is_valid_email(form_data['email']): flash('Please enter a valid email address.', 'error') - return render_template('request.html'), 400 - rid = create_request( - name=request.form.get('name', '').strip(), - email=email, - hobbies=request.form.get('hobbies', '').strip(), - notable_facts=request.form.get('notable_facts', '').strip(), - style_genre=request.form.get('style_genre', '').strip(), - extra_requests=request.form.get('extra_requests', '').strip(), - vocal_gender=request.form.get('vocal_gender', '').strip(), - ) + return render_template('request.html', form=form_data), 400 + rid = create_request(**form_data) # Send confirmation email with a summary of what the customer asked for. req = get_request_by_id(rid) @@ -365,7 +365,7 @@ def request_form(): flash('Your request has been submitted! Check your email soon.', 'success') return redirect(url_for('thanks', rid=rid)) - return render_template('request.html') + return render_template('request.html', form=None) @app.route('/thanks/') diff --git a/templates/request.html b/templates/request.html index d4b0148..be53136 100644 --- a/templates/request.html +++ b/templates/request.html @@ -105,50 +105,65 @@ font-size:1.3rem; vertical-align:middle; } + .flash{ + padding:.8rem; + background:#064e3b; + border-radius:.5rem; + margin-bottom:1rem; + } + .flash.error{background:#450a0a;}
- - + + -
-

🎵 Get Your Custom Theme Song 🎶

-

Tell us about yourself and we'll craft a one-of-a-kind song just for you.

+
+

🎵 Get Your Custom Theme Song 🎶

+

Tell us about yourself and we'll craft a one-of-a-kind song just for you.

-
- - + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} +
{{ message }}
+ {% endfor %} + {% endif %} + {% endwith %} - - + + + - - + + - - + + - - + + - - + + - - + + - -
-

Your info is only used to create and deliver your song.

-
+ + + + + +

Your info is only used to create and deliver your song.

+