refactor
This commit is contained in:
parent
e7063b6514
commit
7879b854a3
|
@ -57,21 +57,7 @@ class UserAdmin(SLModelView):
|
||||||
"Are you sure you want to edu-upgrade selected users?",
|
"Are you sure you want to edu-upgrade selected users?",
|
||||||
)
|
)
|
||||||
def action_edu_upgrade(self, ids):
|
def action_edu_upgrade(self, ids):
|
||||||
query = User.query.filter(User.id.in_(ids))
|
upgrade("Edu", ids, is_giveaway=True)
|
||||||
|
|
||||||
for user in query.all():
|
|
||||||
if user.is_premium() and not user.in_trial():
|
|
||||||
continue
|
|
||||||
|
|
||||||
ManualSubscription.create(
|
|
||||||
user_id=user.id,
|
|
||||||
end_at=arrow.now().shift(years=1, days=1),
|
|
||||||
comment="Edu",
|
|
||||||
is_giveaway=True,
|
|
||||||
commit=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
flash(f"{user} is edu upgraded")
|
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
"charity_org_upgrade",
|
"charity_org_upgrade",
|
||||||
|
@ -79,21 +65,7 @@ class UserAdmin(SLModelView):
|
||||||
"Are you sure you want to upgrade selected users using the Charity organization program?",
|
"Are you sure you want to upgrade selected users using the Charity organization program?",
|
||||||
)
|
)
|
||||||
def action_charity_org_upgrade(self, ids):
|
def action_charity_org_upgrade(self, ids):
|
||||||
query = User.query.filter(User.id.in_(ids))
|
upgrade("Charity Organization", ids, is_giveaway=True)
|
||||||
|
|
||||||
for user in query.all():
|
|
||||||
if user.is_premium() and not user.in_trial():
|
|
||||||
continue
|
|
||||||
|
|
||||||
ManualSubscription.create(
|
|
||||||
user_id=user.id,
|
|
||||||
end_at=arrow.now().shift(years=1, days=1),
|
|
||||||
comment="Charity Organization",
|
|
||||||
is_giveaway=True,
|
|
||||||
commit=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
flash(f"{user} is chariry organization upgraded")
|
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
"cash_upgrade",
|
"cash_upgrade",
|
||||||
|
@ -101,21 +73,7 @@ class UserAdmin(SLModelView):
|
||||||
"Are you sure you want to cash-upgrade selected users?",
|
"Are you sure you want to cash-upgrade selected users?",
|
||||||
)
|
)
|
||||||
def action_cash_upgrade(self, ids):
|
def action_cash_upgrade(self, ids):
|
||||||
query = User.query.filter(User.id.in_(ids))
|
upgrade("Cash", ids, is_giveaway=False)
|
||||||
|
|
||||||
for user in query.all():
|
|
||||||
if user.is_premium() and not user.in_trial():
|
|
||||||
continue
|
|
||||||
|
|
||||||
ManualSubscription.create(
|
|
||||||
user_id=user.id,
|
|
||||||
end_at=arrow.now().shift(years=1, days=1),
|
|
||||||
comment="Cash",
|
|
||||||
is_giveaway=False,
|
|
||||||
commit=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
flash(f"{user} is cash upgraded")
|
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
"monero_upgrade",
|
"monero_upgrade",
|
||||||
|
@ -123,21 +81,25 @@ class UserAdmin(SLModelView):
|
||||||
"Are you sure you want to monero-upgrade selected users?",
|
"Are you sure you want to monero-upgrade selected users?",
|
||||||
)
|
)
|
||||||
def action_monero_upgrade(self, ids):
|
def action_monero_upgrade(self, ids):
|
||||||
query = User.query.filter(User.id.in_(ids))
|
upgrade("Monero", ids, is_giveaway=False)
|
||||||
|
|
||||||
for user in query.all():
|
|
||||||
if user.is_premium() and not user.in_trial():
|
|
||||||
continue
|
|
||||||
|
|
||||||
ManualSubscription.create(
|
def upgrade(way: str, ids: [int], is_giveaway: bool):
|
||||||
user_id=user.id,
|
query = User.query.filter(User.id.in_(ids))
|
||||||
end_at=arrow.now().shift(years=1, days=1),
|
|
||||||
comment="Monero",
|
|
||||||
is_giveaway=False,
|
|
||||||
commit=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
flash(f"{user} is Monero upgraded")
|
for user in query.all():
|
||||||
|
if user.is_premium() and not user.in_trial():
|
||||||
|
continue
|
||||||
|
|
||||||
|
ManualSubscription.create(
|
||||||
|
user_id=user.id,
|
||||||
|
end_at=arrow.now().shift(years=1, days=1),
|
||||||
|
comment=way,
|
||||||
|
is_giveaway=is_giveaway,
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
flash(f"{user} is {way} upgraded")
|
||||||
|
|
||||||
|
|
||||||
class EmailLogAdmin(SLModelView):
|
class EmailLogAdmin(SLModelView):
|
||||||
|
|
Loading…
Reference in a new issue