Added extend subscription log
This commit is contained in:
parent
b44904bc15
commit
553d8976be
|
@ -59,7 +59,7 @@ class SLModelView(sqla.ModelView):
|
||||||
admin_user_id=current_user.id,
|
admin_user_id=current_user.id,
|
||||||
model=model.__class__.__name__,
|
model=model.__class__.__name__,
|
||||||
model_id=model.id,
|
model_id=model.id,
|
||||||
action=auditAction,
|
action=auditAction.value,
|
||||||
data=changes,
|
data=changes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class SLModelView(sqla.ModelView):
|
||||||
admin_user_id=current_user.id,
|
admin_user_id=current_user.id,
|
||||||
model=model.__class__.__name__,
|
model=model.__class__.__name__,
|
||||||
model_id=model.id,
|
model_id=model.id,
|
||||||
action=AuditLogActionEnum.delete_object,
|
action=AuditLogActionEnum.delete_object.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +159,9 @@ class UserAdmin(SLModelView):
|
||||||
user.trial_end = arrow.now().shift(weeks=1)
|
user.trial_end = arrow.now().shift(weeks=1)
|
||||||
|
|
||||||
flash(f"Extend trial for {user} to {user.trial_end}", "success")
|
flash(f"Extend trial for {user} to {user.trial_end}", "success")
|
||||||
AdminAuditLog.extend_trial_1w(current_user.id, user.id, user.trial_end)
|
AdminAuditLog.extend_trial(
|
||||||
|
current_user.id, user.id, user.trial_end, "1 week"
|
||||||
|
)
|
||||||
|
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
|
||||||
|
@ -288,6 +290,9 @@ class ManualSubscriptionAdmin(SLModelView):
|
||||||
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
||||||
ms.end_at = ms.end_at.shift(years=1)
|
ms.end_at = ms.end_at.shift(years=1)
|
||||||
flash(f"Extend subscription for 1 year for {ms.user}", "success")
|
flash(f"Extend subscription for 1 year for {ms.user}", "success")
|
||||||
|
AdminAuditLog.extend_subscription(
|
||||||
|
current_user.id, ms.user.id, ms.end_at, "1 year"
|
||||||
|
)
|
||||||
|
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
|
||||||
|
@ -300,6 +305,9 @@ class ManualSubscriptionAdmin(SLModelView):
|
||||||
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
for ms in ManualSubscription.filter(ManualSubscription.id.in_(ids)):
|
||||||
ms.end_at = ms.end_at.shift(months=1)
|
ms.end_at = ms.end_at.shift(months=1)
|
||||||
flash(f"Extend subscription for 1 month for {ms.user}", "success")
|
flash(f"Extend subscription for 1 month for {ms.user}", "success")
|
||||||
|
AdminAuditLog.extend_subscription(
|
||||||
|
current_user.id, ms.user.id, ms.end_at, "1 month"
|
||||||
|
)
|
||||||
|
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,7 @@ class AuditLogActionEnum(EnumE):
|
||||||
extend_trial = 4
|
extend_trial = 4
|
||||||
disable_2fa = 5
|
disable_2fa = 5
|
||||||
logged_as_user = 6
|
logged_as_user = 6
|
||||||
|
extend_subscription = 7
|
||||||
|
|
||||||
|
|
||||||
class Hibp(Base, ModelMixin):
|
class Hibp(Base, ModelMixin):
|
||||||
|
@ -2914,7 +2915,7 @@ class AdminAuditLog(Base):
|
||||||
):
|
):
|
||||||
cls.create(
|
cls.create(
|
||||||
admin_user_id=admin_user_id,
|
admin_user_id=admin_user_id,
|
||||||
action=AuditLogActionEnum.manual_upgrade,
|
action=AuditLogActionEnum.manual_upgrade.value,
|
||||||
model="User",
|
model="User",
|
||||||
model_id=user_id,
|
model_id=user_id,
|
||||||
data={
|
data={
|
||||||
|
@ -2924,13 +2925,18 @@ class AdminAuditLog(Base):
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def extend_trial_1w(cls, admin_user_id: int, user_id: int, trial_end: arrow.Arrow):
|
def extend_trial(
|
||||||
|
cls, admin_user_id: int, user_id: int, trial_end: arrow.Arrow, extend_time: str
|
||||||
|
):
|
||||||
cls.create(
|
cls.create(
|
||||||
admin_user_id=admin_user_id,
|
admin_user_id=admin_user_id,
|
||||||
action=AuditLogActionEnum.extend_trial,
|
action=AuditLogActionEnum.extend_trial.value,
|
||||||
model="User",
|
model="User",
|
||||||
model_id=user_id,
|
model_id=user_id,
|
||||||
data={"trial_end": trial_end.format(arrow.FORMAT_RFC3339)},
|
data={
|
||||||
|
"trial_end": trial_end.format(arrow.FORMAT_RFC3339),
|
||||||
|
"extend_time": extend_time,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -2939,7 +2945,7 @@ class AdminAuditLog(Base):
|
||||||
):
|
):
|
||||||
cls.create(
|
cls.create(
|
||||||
admin_user_id=admin_user_id,
|
admin_user_id=admin_user_id,
|
||||||
action=AuditLogActionEnum.disable_2fa,
|
action=AuditLogActionEnum.disable_2fa.value,
|
||||||
model="User",
|
model="User",
|
||||||
model_id=user_id,
|
model_id=user_id,
|
||||||
data={"had_otp": had_otp, "had_fido": had_fido},
|
data={"had_otp": had_otp, "had_fido": had_fido},
|
||||||
|
@ -2949,10 +2955,29 @@ class AdminAuditLog(Base):
|
||||||
def logged_as_user(cls, admin_user_id: int, user_id: int):
|
def logged_as_user(cls, admin_user_id: int, user_id: int):
|
||||||
cls.create(
|
cls.create(
|
||||||
admin_user_id=admin_user_id,
|
admin_user_id=admin_user_id,
|
||||||
action=AuditLogActionEnum.logged_as_user,
|
action=AuditLogActionEnum.logged_as_user.value,
|
||||||
model="User",
|
model="User",
|
||||||
model_id=user_id,
|
model_id=user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def extend_subscription(
|
||||||
|
cls,
|
||||||
|
admin_user_id: int,
|
||||||
|
user_id: int,
|
||||||
|
subscription_end: arrow.Arrow,
|
||||||
|
extend_time: str,
|
||||||
|
):
|
||||||
|
cls.create(
|
||||||
|
admin_user_id=admin_user_id,
|
||||||
|
action=AuditLogActionEnum.extend_subscription.value,
|
||||||
|
model="User",
|
||||||
|
model_id=user_id,
|
||||||
|
data={
|
||||||
|
"subscription_end": subscription_end.format(arrow.FORMAT_RFC3339),
|
||||||
|
"extend_time": extend_time,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
Loading…
Reference in a new issue