Skip to content

Commit

Permalink
billing: Rename RealmAuditLog.REALM_CARD_ADDED.
Browse files Browse the repository at this point in the history
  • Loading branch information
rishig committed Aug 10, 2018
1 parent bdb6d82 commit d33d7e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion zerver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ class RealmAuditLog(models.Model):
extra_data = models.TextField(null=True) # type: Optional[str]

STRIPE_CUSTOMER_CREATED = 'stripe_customer_created'
REALM_CARD_ADDED = 'realm_card_added'
STRIPE_CARD_ADDED = 'stripe_card_added'
REALM_PLAN_STARTED = 'realm_plan_started'
REALM_PLAN_QUANTITY_RESET = 'realm_plan_quantity_reset'

Expand Down
3 changes: 2 additions & 1 deletion zilencer/lib/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str)
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CUSTOMER_CREATED,
event_time=event_time)
RealmAuditLog.objects.create(
realm=user.realm, acting_user=user, event_type=RealmAuditLog.REALM_CARD_ADDED, event_time=event_time)
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_ADDED,
event_time=event_time)
Customer.objects.create(
realm=realm,
stripe_customer_id=stripe_customer.id,
Expand Down
4 changes: 2 additions & 2 deletions zilencer/tests/test_stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_initial_upgrade(self, mock_create_subscription: mock.Mock,
.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.REALM_CARD_ADDED, timestamp_to_datetime(self.customer_created)),
(RealmAuditLog.STRIPE_CARD_ADDED, timestamp_to_datetime(self.customer_created)),
(RealmAuditLog.REALM_PLAN_STARTED, timestamp_to_datetime(self.subscription_created)),
])
# Check that we correctly updated Realm
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_upgrade_with_outdated_seat_count(self, mock_create_subscription: mock.M
'requires_billing_update')[:4])[::-1]
self.assertEqual(audit_log_entries, [
(RealmAuditLog.STRIPE_CUSTOMER_CREATED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.REALM_CARD_ADDED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.STRIPE_CARD_ADDED, timestamp_to_datetime(self.customer_created), False),
(RealmAuditLog.REALM_PLAN_STARTED, timestamp_to_datetime(self.subscription_created), False),
(RealmAuditLog.REALM_PLAN_QUANTITY_RESET, timestamp_to_datetime(self.subscription_created), True),
])
Expand Down

0 comments on commit d33d7e1

Please sign in to comment.