allow user having manual sub or canceled sub to upgrade to lifetime
This commit is contained in:
parent
89c41f972c
commit
a0cdf3ae95
|
@ -23,9 +23,15 @@ class CouponForm(FlaskForm):
|
|||
@dashboard_bp.route("/lifetime_licence", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def lifetime_licence():
|
||||
# sanity check: make sure this page is only for free user
|
||||
if current_user.lifetime_or_active_subscription():
|
||||
flash("You are already a premium user", "warning")
|
||||
if current_user.lifetime:
|
||||
flash("You already have a lifetime licence", "warning")
|
||||
return redirect(url_for("dashboard.index"))
|
||||
|
||||
# user needs to cancel active subscription first
|
||||
# to avoid being charged
|
||||
sub = current_user.get_subscription()
|
||||
if sub and not sub.cancelled:
|
||||
flash("Please cancel your current subscription first", "warning")
|
||||
return redirect(url_for("dashboard.index"))
|
||||
|
||||
coupon_form = CouponForm()
|
||||
|
|
|
@ -322,7 +322,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
names = self.name.split(" ")
|
||||
return "".join([n[0].upper() for n in names if n])
|
||||
|
||||
def get_subscription(self):
|
||||
def get_subscription(self) -> "Subscription":
|
||||
"""return *active* subscription
|
||||
TODO: support user unsubscribe and re-subscribe
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue