mirror of
https://github.com/simple-login/app.git
synced 2024-09-21 07:25:59 +08:00
handle the case user mistakenly use a lifetime coupon on the coupon page
This commit is contained in:
parent
416eafaeb9
commit
324cc8734b
|
@ -8,12 +8,14 @@ from app.config import ADMIN_EMAIL
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.db import Session
|
from app.db import Session
|
||||||
from app.email_utils import send_email
|
from app.email_utils import send_email
|
||||||
|
from app.log import LOG
|
||||||
from app.models import (
|
from app.models import (
|
||||||
ManualSubscription,
|
ManualSubscription,
|
||||||
Coupon,
|
Coupon,
|
||||||
Subscription,
|
Subscription,
|
||||||
AppleSubscription,
|
AppleSubscription,
|
||||||
CoinbaseSubscription,
|
CoinbaseSubscription,
|
||||||
|
LifetimeCoupon,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +26,15 @@ class CouponForm(FlaskForm):
|
||||||
@dashboard_bp.route("/coupon", methods=["GET", "POST"])
|
@dashboard_bp.route("/coupon", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def coupon_route():
|
def coupon_route():
|
||||||
|
coupon_form = CouponForm()
|
||||||
|
|
||||||
|
if coupon_form.validate_on_submit():
|
||||||
|
code = coupon_form.code.data
|
||||||
|
if LifetimeCoupon.get_by(code=code):
|
||||||
|
LOG.d("redirect %s to lifetime page instead", current_user)
|
||||||
|
flash("Redirect to the lifetime coupon page instead", "success")
|
||||||
|
return redirect(url_for("dashboard.lifetime_licence"))
|
||||||
|
|
||||||
# handle case user already has an active subscription via another channel (Paddle, Apple, etc)
|
# handle case user already has an active subscription via another channel (Paddle, Apple, etc)
|
||||||
can_use_coupon = True
|
can_use_coupon = True
|
||||||
|
|
||||||
|
@ -48,8 +59,6 @@ def coupon_route():
|
||||||
flash("You already have another subscription.", "warning")
|
flash("You already have another subscription.", "warning")
|
||||||
return redirect(url_for("dashboard.index"))
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
coupon_form = CouponForm()
|
|
||||||
|
|
||||||
if coupon_form.validate_on_submit():
|
if coupon_form.validate_on_submit():
|
||||||
code = coupon_form.code.data
|
code = coupon_form.code.data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue