billing: Rename RealmAuditLog.STRIPE_CARD_ADDED to STRIPE_CARD_CHANGED.

This commit is contained in:
Vishnu Ks 2018-09-05 13:10:29 +05:30 committed by Rishi Gupta
parent 7822ef38c2
commit 3e86fa84ea
3 changed files with 8 additions and 8 deletions

View File

@ -2202,7 +2202,7 @@ class RealmAuditLog(models.Model):
extra_data = models.TextField(null=True) # type: Optional[str]
STRIPE_CUSTOMER_CREATED = 'stripe_customer_created'
STRIPE_CARD_ADDED = 'stripe_card_added'
STRIPE_CARD_CHANGED = 'stripe_card_changed'
STRIPE_PLAN_CHANGED = 'stripe_plan_changed'
STRIPE_PLAN_QUANTITY_RESET = 'stripe_plan_quantity_reset'

View File

@ -185,7 +185,7 @@ def do_create_customer(user: UserProfile, stripe_token: Optional[str]=None,
event_time=event_time)
if stripe_token is not None:
RealmAuditLog.objects.create(
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_ADDED,
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_CHANGED,
event_time=event_time)
Customer.objects.create(realm=realm, stripe_customer_id=stripe_customer.id)
user.is_billing_admin = True
@ -201,7 +201,7 @@ def do_replace_payment_source(user: UserProfile, stripe_token: str) -> stripe.Cu
# invoices: https://stripe.com/docs/api#update_customer
updated_stripe_customer = stripe_customer.save()
RealmAuditLog.objects.create(
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_ADDED,
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_CHANGED,
event_time=timezone_now())
return updated_stripe_customer

View File

@ -158,7 +158,7 @@ class StripeTest(ZulipTestCase):
.values_list('event_type', 'event_time').order_by('id'))
self.assertEqual(audit_log_entries, [
(RealmAuditLog.STRIPE_CUSTOMER_CREATED, timestamp_to_datetime(self.customer_created)),
(RealmAuditLog.STRIPE_CARD_ADDED, timestamp_to_datetime(self.customer_created)),
(RealmAuditLog.STRIPE_CARD_CHANGED, timestamp_to_datetime(self.customer_created)),
(RealmAuditLog.STRIPE_PLAN_CHANGED, timestamp_to_datetime(self.subscription_created)),
(RealmAuditLog.REALM_PLAN_TYPE_CHANGED, Kandra()),
])
@ -233,7 +233,7 @@ class StripeTest(ZulipTestCase):
'requires_billing_update')[:5])[::-1]
self.assertEqual(audit_log_entries, [
(RealmAuditLog.STRIPE_CUSTOMER_CREATED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.STRIPE_CARD_ADDED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.STRIPE_CARD_CHANGED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.STRIPE_PLAN_CHANGED, timestamp_to_datetime(self.subscription_created), False),
(RealmAuditLog.STRIPE_PLAN_QUANTITY_RESET, timestamp_to_datetime(self.subscription_created), True),
(RealmAuditLog.REALM_PLAN_TYPE_CHANGED, Kandra(), False),
@ -262,7 +262,7 @@ class StripeTest(ZulipTestCase):
audit_log_entries = list(RealmAuditLog.objects.filter(acting_user=user)
.values_list('event_type', flat=True).order_by('id'))
self.assertEqual(audit_log_entries, [RealmAuditLog.STRIPE_CUSTOMER_CREATED,
RealmAuditLog.STRIPE_CARD_ADDED])
RealmAuditLog.STRIPE_CARD_CHANGED])
# Check that we did not update Realm
realm = get_realm("zulip")
self.assertFalse(realm.has_seat_based_plan)
@ -288,8 +288,8 @@ class StripeTest(ZulipTestCase):
audit_log_entries = list(RealmAuditLog.objects.filter(acting_user=user)
.values_list('event_type', flat=True).order_by('id'))
self.assertEqual(audit_log_entries, [RealmAuditLog.STRIPE_CUSTOMER_CREATED,
RealmAuditLog.STRIPE_CARD_ADDED,
RealmAuditLog.STRIPE_CARD_ADDED,
RealmAuditLog.STRIPE_CARD_CHANGED,
RealmAuditLog.STRIPE_CARD_CHANGED,
RealmAuditLog.STRIPE_PLAN_CHANGED,
RealmAuditLog.REALM_PLAN_TYPE_CHANGED])
# Check that we correctly updated Realm