mirror of https://github.com/zulip/zulip.git
stripe: Save a query to get CustomerPlan for sponsored customers.
This commit is contained in:
parent
44c8e25e32
commit
d4a852e97c
|
@ -4098,11 +4098,6 @@ def get_push_status_for_remote_request(
|
|||
billing_session = RemoteServerBillingSession(remote_server)
|
||||
customer = billing_session.get_customer()
|
||||
|
||||
if customer is not None:
|
||||
current_plan = get_current_plan_by_customer(customer)
|
||||
else:
|
||||
current_plan = None
|
||||
|
||||
if billing_session.is_sponsored():
|
||||
return PushNotificationsEnabledStatus(
|
||||
can_push=True,
|
||||
|
@ -4110,6 +4105,11 @@ def get_push_status_for_remote_request(
|
|||
message="Community plan",
|
||||
)
|
||||
|
||||
if customer is not None:
|
||||
current_plan = get_current_plan_by_customer(customer)
|
||||
else:
|
||||
current_plan = None
|
||||
|
||||
if current_plan is not None:
|
||||
if current_plan.status in [
|
||||
CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE,
|
||||
|
|
|
@ -2191,7 +2191,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
|||
|
||||
with mock.patch(
|
||||
"zilencer.views.RemoteRealmBillingSession.get_customer", return_value=dummy_customer
|
||||
) as m:
|
||||
):
|
||||
with mock.patch(
|
||||
"corporate.lib.stripe.get_current_plan_by_customer", return_value=None
|
||||
) as m:
|
||||
|
@ -2200,7 +2200,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
|||
return_value=11,
|
||||
):
|
||||
send_server_data_to_push_bouncer(consider_usage_statistics=False)
|
||||
m.assert_called()
|
||||
m.assert_not_called()
|
||||
realms = Realm.objects.all()
|
||||
for realm in realms:
|
||||
self.assertEqual(realm.push_notifications_enabled, True)
|
||||
|
|
Loading…
Reference in New Issue