Set user.paid_lifetime if paid coupon

This commit is contained in:
Son NK 2020-10-21 19:31:25 +02:00
parent 050c2feaeb
commit 4f7b30c204
1 changed files with 3 additions and 2 deletions

View File

@ -33,11 +33,12 @@ def lifetime_licence():
if coupon_form.validate_on_submit():
code = coupon_form.code.data
coupon = LifetimeCoupon.get_by(code=code)
coupon: LifetimeCoupon = LifetimeCoupon.get_by(code=code)
if coupon and coupon.nb_used > 0:
coupon.nb_used -= 1
current_user.lifetime = True
if coupon.paid:
current_user.paid_lifetime = True
db.session.commit()
# notify admin