mirror of https://github.com/zulip/zulip.git
models: Rename several RealmAuditlog event types to past tense.
These event types haven't been used in production yet, and thus are save to change without a migration.
This commit is contained in:
parent
2d5ef27874
commit
28167585b1
|
@ -1984,10 +1984,10 @@ class RealmAuditLog(models.Model):
|
|||
requires_billing_update = models.BooleanField(default=False) # type: bool
|
||||
extra_data = models.TextField(null=True) # type: Optional[str]
|
||||
|
||||
STRIPE_START = 'stripe_start'
|
||||
CARD_ADDED = 'card_added'
|
||||
PLAN_START = 'plan_start'
|
||||
PLAN_UPDATE_QUANTITY = 'plan_update_quantity'
|
||||
REALM_STRIPE_INITIALIZED = 'realm_stripe_initialized'
|
||||
REALM_CARD_ADDED = 'realm_card_added'
|
||||
REALM_PLAN_STARTED = 'realm_plan_started'
|
||||
PLAN_QUANTITY_UPDATED = 'plan_quantity_updated'
|
||||
|
||||
USER_CREATED = 'user_created'
|
||||
USER_ACTIVATED = 'user_activated'
|
||||
|
|
|
@ -112,9 +112,10 @@ def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str)
|
|||
print(''.join(['"create_customer": ', str(stripe_customer), ','])) # nocoverage
|
||||
event_time = timestamp_to_datetime(stripe_customer.created)
|
||||
RealmAuditLog.objects.create(
|
||||
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_START, event_time=event_time)
|
||||
realm=user.realm, acting_user=user, event_type=RealmAuditLog.REALM_STRIPE_INITIALIZED,
|
||||
event_time=event_time)
|
||||
RealmAuditLog.objects.create(
|
||||
realm=user.realm, acting_user=user, event_type=RealmAuditLog.CARD_ADDED, event_time=event_time)
|
||||
realm=user.realm, acting_user=user, event_type=RealmAuditLog.REALM_CARD_ADDED, event_time=event_time)
|
||||
Customer.objects.create(
|
||||
realm=realm,
|
||||
stripe_customer_id=stripe_customer.id,
|
||||
|
@ -144,7 +145,7 @@ def do_subscribe_customer_to_plan(stripe_customer: stripe.Customer, stripe_plan_
|
|||
RealmAuditLog.objects.create(
|
||||
realm=customer.realm,
|
||||
acting_user=customer.billing_user,
|
||||
event_type=RealmAuditLog.PLAN_START,
|
||||
event_type=RealmAuditLog.REALM_PLAN_STARTED,
|
||||
event_time=timestamp_to_datetime(stripe_subscription.created),
|
||||
extra_data=ujson.dumps({'plan': stripe_plan_id, 'quantity': seat_count}))
|
||||
|
||||
|
@ -152,7 +153,7 @@ def do_subscribe_customer_to_plan(stripe_customer: stripe.Customer, stripe_plan_
|
|||
if seat_count != current_seat_count:
|
||||
RealmAuditLog.objects.create(
|
||||
realm=customer.realm,
|
||||
event_type=RealmAuditLog.PLAN_UPDATE_QUANTITY,
|
||||
event_type=RealmAuditLog.PLAN_QUANTITY_UPDATED,
|
||||
event_time=timestamp_to_datetime(stripe_subscription.created),
|
||||
requires_billing_update=True,
|
||||
extra_data=ujson.dumps({'quantity': current_seat_count}))
|
||||
|
|
|
@ -117,9 +117,9 @@ class StripeTest(ZulipTestCase):
|
|||
audit_log_entries = list(RealmAuditLog.objects.filter(acting_user=self.user)
|
||||
.values_list('event_type', 'event_time').order_by('id'))
|
||||
self.assertEqual(audit_log_entries, [
|
||||
(RealmAuditLog.STRIPE_START, timestamp_to_datetime(self.customer_created)),
|
||||
(RealmAuditLog.CARD_ADDED, timestamp_to_datetime(self.customer_created)),
|
||||
(RealmAuditLog.PLAN_START, timestamp_to_datetime(self.subscription_created)),
|
||||
(RealmAuditLog.REALM_STRIPE_INITIALIZED, timestamp_to_datetime(self.customer_created)),
|
||||
(RealmAuditLog.REALM_CARD_ADDED, timestamp_to_datetime(self.customer_created)),
|
||||
(RealmAuditLog.REALM_PLAN_STARTED, timestamp_to_datetime(self.subscription_created)),
|
||||
])
|
||||
# Check that we correctly updated Realm
|
||||
realm = get_realm("zulip")
|
||||
|
@ -183,19 +183,19 @@ class StripeTest(ZulipTestCase):
|
|||
}],
|
||||
prorate=True,
|
||||
tax_percent=0)
|
||||
# Check that we have the PLAN_UPDATE_QUANTITY entry, and that we
|
||||
# Check that we have the PLAN_QUANTITY_UPDATED entry, and that we
|
||||
# correctly handled the requires_billing_update field
|
||||
audit_log_entries = list(RealmAuditLog.objects.order_by('-id')
|
||||
.values_list('event_type', 'event_time',
|
||||
'requires_billing_update')[:4])[::-1]
|
||||
self.assertEqual(audit_log_entries, [
|
||||
(RealmAuditLog.STRIPE_START, timestamp_to_datetime(self.customer_created), False),
|
||||
(RealmAuditLog.CARD_ADDED, timestamp_to_datetime(self.customer_created), False),
|
||||
(RealmAuditLog.PLAN_START, timestamp_to_datetime(self.subscription_created), False),
|
||||
(RealmAuditLog.PLAN_UPDATE_QUANTITY, timestamp_to_datetime(self.subscription_created), True),
|
||||
(RealmAuditLog.REALM_STRIPE_INITIALIZED, timestamp_to_datetime(self.customer_created), False),
|
||||
(RealmAuditLog.REALM_CARD_ADDED, timestamp_to_datetime(self.customer_created), False),
|
||||
(RealmAuditLog.REALM_PLAN_STARTED, timestamp_to_datetime(self.subscription_created), False),
|
||||
(RealmAuditLog.PLAN_QUANTITY_UPDATED, timestamp_to_datetime(self.subscription_created), True),
|
||||
])
|
||||
self.assertEqual(ujson.loads(RealmAuditLog.objects.filter(
|
||||
event_type=RealmAuditLog.PLAN_UPDATE_QUANTITY).values_list('extra_data', flat=True).first()),
|
||||
event_type=RealmAuditLog.PLAN_QUANTITY_UPDATED).values_list('extra_data', flat=True).first()),
|
||||
{'quantity': new_seat_count})
|
||||
|
||||
@mock.patch("zilencer.lib.stripe.STRIPE_PUBLISHABLE_KEY", "stripe_publishable_key")
|
||||
|
|
Loading…
Reference in New Issue