From 19c067fa179c762ffc1c3d338c6152456a91aea6 Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Tue, 13 Jul 2021 08:55:04 +0200 Subject: [PATCH] add coupon admin --- app/admin_model.py | 5 +++++ server.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/admin_model.py b/app/admin_model.py index 29642b22..8b73cef7 100644 --- a/app/admin_model.py +++ b/app/admin_model.py @@ -160,6 +160,11 @@ class LifetimeCouponAdmin(SLModelView): can_create = True +class CouponAdmin(SLModelView): + can_edit = True + can_create = True + + class ManualSubscriptionAdmin(SLModelView): can_edit = True column_searchable_list = ["id", "user.email"] diff --git a/server.py b/server.py index 3df3b5a5..e37c37e3 100644 --- a/server.py +++ b/server.py @@ -37,6 +37,7 @@ from app.admin_model import ( ClientAdmin, ReferralAdmin, PayoutAdmin, + CouponAdmin, ) from app.api.base import api_bp from app.auth.base import auth_bp @@ -98,6 +99,7 @@ from app.models import ( RefusedEmail, ManualSubscription, Payout, + Coupon, ) from app.monitor.base import monitor_bp from app.oauth.base import oauth_bp @@ -266,7 +268,8 @@ def fake_data(): commit=True, ) - LifetimeCoupon.create(code="coupon", nb_used=10, commit=True) + LifetimeCoupon.create(code="lifetime-coupon", nb_used=10, commit=True) + Coupon.create(code="coupon", commit=True) # Create a subscription for user Subscription.create( @@ -848,6 +851,7 @@ def init_admin(app): admin.add_view(MailboxAdmin(Mailbox, db.session)) admin.add_view(EmailLogAdmin(EmailLog, db.session)) admin.add_view(LifetimeCouponAdmin(LifetimeCoupon, db.session)) + admin.add_view(CouponAdmin(Coupon, db.session)) admin.add_view(ManualSubscriptionAdmin(ManualSubscription, db.session)) admin.add_view(ClientAdmin(Client, db.session)) admin.add_view(ReferralAdmin(Referral, db.session))