Skip to content

Commit

Permalink
wip #1219 adding a form to change the thankyou page url
Browse files Browse the repository at this point in the history
  • Loading branch information
joeltejeda committed Sep 1, 2023
1 parent 6245c76 commit 3b174dc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
16 changes: 15 additions & 1 deletion subscribie/blueprints/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
WelcomeEmailTemplateForm,
SetReplyToEmailForm,
UploadFilesForm,
customThankYouUrlForm,
)
from subscribie.auth import (
login_required,
Expand Down Expand Up @@ -1941,7 +1942,20 @@ def vat_settings():
@admin.route("/change-thank-you-url", methods=["GET", "POST"])
@login_required
def change_thank_you_url():
return "Todo"
settings = Setting.query.first() # Get current shop settings
form = customThankYouUrlForm()
if request.method == "POST":
custom_thank_you_url = form.url.data
# here we will need to insert the url inside the database
os.environ[
"REDIRECT_THANKYOU_PAGE"
] = custom_thank_you_url # this is just an example
flash(f"CUSTOM URL CHANGED to {custom_thank_you_url}")
return redirect(url_for("admin.change_thank_you_url", settings=settings))
return render_template(
"admin/settings/custom_thank_you_page.html", settings=settings, form=form
)


@admin.route("/donate-enabled-settings", methods=["GET", "POST"])
@login_required
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "admin/layout.html" %}
{% block title %} Add Custom Thank you page{% endblock %}

{% block body %}

<h2 class="text-center text-dark mb-3">Custom thank you page url</h2>

<div class="container">
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Shop</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('admin.dashboard') }}">Manage My Shop</a></li>
<li class="breadcrumb-item active" aria-current="page">Custom thank you page url</li>
</ul>
</div>

<main>
<div class="section">
<div class="container">

<div class="row row-cols-1 row-cols-md-2">
<div class="col-md-7">
<p>
Please type the exact url you want your subscribers to visit after subscribing to a plan.
</p>

<form action="" method="POST" action="/">
<div class="form-group">
<label for="email">Your URL:</label>
<input type="text" name="url" class="form-control"
id="url" aria-describedby="emailHelp"
placeholder="https://google.com" required>
</div>
<button type="submit" class="btn btn-primary btn-block mb-3">Save</button>
</form>
</div>

</div>

</div> <!-- end container-->
</div> <!-- end section-->
</main>



{% endblock %}
11 changes: 9 additions & 2 deletions subscribie/blueprints/checkout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,15 @@ def thankyou():
is_donation=is_donation,
subscription_uuid=uuid,
)

return render_template("thankyou.html")
# here we will need to get the value from the database
redirect_thankyou_page = os.getenv(
"REDIRECT_THANKYOU_PAGE"
) # this is just an example
breakpoint()
if redirect_thankyou_page == "default":
return render_template("thankyou.html")
else:
return redirect(redirect_thankyou_page) # ex. https://google.com


@checkout.route("/stripe-create-checkout-session", methods=["POST"])
Expand Down
4 changes: 4 additions & 0 deletions subscribie/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,9 @@ class SetReplyToEmailForm(StripWhitespaceForm):
email = StringField("email", validators=[DataRequired(), EmailValid()])


class customThankYouUrlForm(StripWhitespaceForm):
url = StringField("url", validators=[DataRequired()], default="default")


class UploadFilesForm(FlaskForm):
upload = MultipleFileField("Files")

0 comments on commit 3b174dc

Please sign in to comment.