From 29fa7c50fdf9fe1956568f9caceca4da03e22ac8 Mon Sep 17 00:00:00 2001 From: jimmyedagawa78 <30567984+jimmyedagawa78@users.noreply.github.com> Date: Thu, 28 Sep 2023 22:31:45 +0530 Subject: [PATCH] #1219 redirect thank you page url (#1232) * #1219 redirect thank you page url * Fix #1219 added new route for thank you URL * wip #1219 adding a form to change the thankyou page url * adding the custom_thank_you_page database column * Fix #1219 updated page text I updated the text on the "add custom thank you page" * FIX #1219 adding url validation * #1219 adding tests * black formatting * Update custom_thank_you_page.html Added bold text and reworded the instructions * Fix #1236 Updated the Shop Settings Heading in the dashboard Added Donations & Thank you Page URL in the heading of Shop Settings * fixing wording * Fix #1219 improve wording on Custom Thank You page URL #1219 added heading to settings page Custom Thank You page URL #1219 less vuage "Your URL" to -> "Custom Thank You page URL:" * #1219 require require_tld=True customThankYouUrlForm * #1219 Please enter a valid URL -> Please enter a valid URL. e.g https://example.com/thankyou * #1219 add form error help feedback * Ref #1219 dont assume form is present, error handling * satify black format error * #1219 remove redundant cudtom thankyou url logic * adding the redirect-to-custom-url test * adding default url button * fixing enable custom url test * renaming file and adding waitForURL after redirect * #1219 spacing * #1219 use custom_thank_you_url, no need for redirect_thankyou_page * #1219 if a custom_thank_you_url is already set, show it to the shop admin * #1219 clarified wording 'once their payment is complete' -> 'once they have completed sign-up for a plan' -m 'because free plans exist, payment is not always taken.' * #1219 remove dead "Click here to reset your shop to use the default Thank You page" text * #1219 Test: no need to order plan. Use free plan for test We're not testing the payment flow there, we're testing the custom thankyou page url' ' * #1219 drop .toMatchSnapshot we dont use that * #1219 remove unecessery entries in the test DAG * Ref #1219 remove uneeded timeout & renamed: e2e/1219_shop_owner_enable_custom_url.spec.js -> e2e/1219_custom_thank_you_url.spec.js * Create pull_request_template.md * #1219 redirect thank you page url * Fix #1219 added new route for thank you URL * wip #1219 adding a form to change the thankyou page url * adding the custom_thank_you_page database column * Fix #1219 updated page text I updated the text on the "add custom thank you page" * FIX #1219 adding url validation * Ref #1219 adding tests * black formatting * Update custom_thank_you_page.html Added bold text and reworded the instructions * Fix #1236 Updated the Shop Settings Heading in the dashboard Added Donations & Thank you Page URL in the heading of Shop Settings * fixing wording * Fix #1219 improve wording on Custom Thank You page URL #1219 added heading to settings page Custom Thank You page URL #1219 less vuage "Your URL" to -> "Custom Thank You page URL:" * #1219 require require_tld=True customThankYouUrlForm * #1219 Please enter a valid URL -> Please enter a valid URL. e.g https://example.com/thankyou * #1219 add form error help feedback * Ref #1219 dont assume form is present, error handling * #1219 remove redundant cudtom thankyou url logic * adding the redirect-to-custom-url test * adding default url button * renaming file and adding waitForURL after redirect * #1219 spacing * #1219 use custom_thank_you_url, no need for redirect_thankyou_page * #1219 if a custom_thank_you_url is already set, show it to the shop admin * #1219 clarified wording 'once their payment is complete' -> 'once they have completed sign-up for a plan' -m 'because free plans exist, payment is not always taken.' * #1219 remove dead "Click here to reset your shop to use the default Thank You page" text * #1219 remove unecessery entries in the test DAG --------- Co-authored-by: Joel Co-authored-by: chrisjsimpson --- ...6b3039b_add_custom_thank_you_url_column.py | 26 ++++++++ subscribie/blueprints/admin/__init__.py | 26 ++++++++ .../admin/templates/admin/dashboard.html | 6 +- .../admin/templates/admin/layout.html | 11 ++++ .../admin/settings/custom_thank_you_page.html | 59 +++++++++++++++++++ subscribie/blueprints/checkout/__init__.py | 12 +++- subscribie/forms.py | 13 ++++ subscribie/models.py | 1 + .../e2e/1219_custom_thank_you_url.spec.js | 38 ++++++++++++ ...criber_order_plan_with_cooling_off.spec.js | 2 +- ..._subscriber_ordering_plan_with_VAT.spec.js | 2 +- .../run-playwright-tests.py | 18 ++++-- .../worker2.spec.js | 4 +- 13 files changed, 208 insertions(+), 10 deletions(-) create mode 100644 migrations/versions/207556b3039b_add_custom_thank_you_url_column.py create mode 100644 subscribie/blueprints/admin/templates/admin/settings/custom_thank_you_page.html create mode 100644 tests/browser-automated-tests-playwright/e2e/1219_custom_thank_you_url.spec.js diff --git a/migrations/versions/207556b3039b_add_custom_thank_you_url_column.py b/migrations/versions/207556b3039b_add_custom_thank_you_url_column.py new file mode 100644 index 00000000..1d290748 --- /dev/null +++ b/migrations/versions/207556b3039b_add_custom_thank_you_url_column.py @@ -0,0 +1,26 @@ +"""add custom thank you url column + +Revision ID: 207556b3039b +Revises: 7640c2a9be5b +Create Date: 2023-09-01 19:35:12.241628 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "207556b3039b" +down_revision = "7640c2a9be5b" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + "setting", sa.Column("custom_thank_you_url", sa.String(), nullable=True) + ) + + +def downgrade(): + pass diff --git a/subscribie/blueprints/admin/__init__.py b/subscribie/blueprints/admin/__init__.py index b2099959..0126be6f 100644 --- a/subscribie/blueprints/admin/__init__.py +++ b/subscribie/blueprints/admin/__init__.py @@ -43,6 +43,7 @@ WelcomeEmailTemplateForm, SetReplyToEmailForm, UploadFilesForm, + customThankYouUrlForm, ) from subscribie.auth import ( login_required, @@ -1938,6 +1939,31 @@ def vat_settings(): return render_template("admin/settings/vat_settings.html", settings=settings) +@admin.route("/change-thank-you-url", methods=["GET", "POST"]) +@login_required +def change_thank_you_url(): + settings = Setting.query.first() # Get current shop settings + form = customThankYouUrlForm() + + if request.method == "POST": + if request.form.get("default"): + settings.custom_thank_you_url = None + database.session.commit() + flash(f"Custom thank you url changed to default") + return render_template( + "admin/settings/custom_thank_you_page.html", + form=form, + ) + + elif form.validate(): + settings.custom_thank_you_url = form.custom_thank_you_url.data + database.session.commit() + flash(f"Custom thank you url changed to: {form.custom_thank_you_url.data}") + return redirect(url_for("admin.change_thank_you_url", form=form)) + return render_template("admin/settings/custom_thank_you_page.html", form=form) + return render_template("admin/settings/custom_thank_you_page.html", form=form) + + @admin.route("/donate-enabled-settings", methods=["GET", "POST"]) @login_required def donations_enabled_settings(): diff --git a/subscribie/blueprints/admin/templates/admin/dashboard.html b/subscribie/blueprints/admin/templates/admin/dashboard.html index 2131eb34..f963f5fc 100644 --- a/subscribie/blueprints/admin/templates/admin/dashboard.html +++ b/subscribie/blueprints/admin/templates/admin/dashboard.html @@ -510,7 +510,7 @@

Templates

@@ -534,6 +534,10 @@

Templates

VAT Settings {% endif %} + + Change Thank You Page/Payment Successful Page URL +
diff --git a/subscribie/blueprints/admin/templates/admin/layout.html b/subscribie/blueprints/admin/templates/admin/layout.html index 6b0edbe0..4a92758b 100644 --- a/subscribie/blueprints/admin/templates/admin/layout.html +++ b/subscribie/blueprints/admin/templates/admin/layout.html @@ -79,6 +79,17 @@
-->
+ {% if form and form.errors %} + + {% endif %} {% with messages = get_flashed_messages() %} {% if messages %}