mirror of https://github.com/zulip/zulip.git
billing: Create is_sponsored_realm function.
This commit is contained in:
parent
cdf683e36f
commit
1eb83cbadc
|
@ -876,6 +876,10 @@ def approve_sponsorship(realm: Realm, *, acting_user: Optional[UserProfile]) ->
|
|||
internal_send_private_message(notification_bot, billing_admin, message)
|
||||
|
||||
|
||||
def is_sponsored_realm(realm: Realm) -> bool:
|
||||
return realm.plan_type == Realm.STANDARD_FREE
|
||||
|
||||
|
||||
def get_discount_for_realm(realm: Realm) -> Optional[Decimal]:
|
||||
customer = get_customer_by_realm(realm)
|
||||
if customer is not None:
|
||||
|
|
|
@ -38,6 +38,7 @@ from corporate.lib.stripe import (
|
|||
invoice_plan,
|
||||
invoice_plans_as_needed,
|
||||
is_realm_on_free_trial,
|
||||
is_sponsored_realm,
|
||||
make_end_of_cycle_updates_if_needed,
|
||||
next_month,
|
||||
process_initial_upgrade,
|
||||
|
@ -3005,6 +3006,14 @@ class BillingHelpersTest(ZulipTestCase):
|
|||
plan.save(update_fields=["status"])
|
||||
self.assertTrue(is_realm_on_free_trial(realm))
|
||||
|
||||
def test_is_sponsored_realm(self) -> None:
|
||||
realm = get_realm("zulip")
|
||||
self.assertFalse(is_sponsored_realm(realm))
|
||||
|
||||
realm.plan_type = Realm.STANDARD_FREE
|
||||
realm.save()
|
||||
self.assertTrue(is_sponsored_realm(realm))
|
||||
|
||||
|
||||
class LicenseLedgerTest(StripeTestCase):
|
||||
def test_add_plan_renewal_if_needed(self) -> None:
|
||||
|
|
|
@ -22,6 +22,7 @@ from corporate.lib.stripe import (
|
|||
downgrade_at_the_end_of_billing_cycle,
|
||||
downgrade_now_without_creating_additional_invoices,
|
||||
get_latest_seat_count,
|
||||
is_sponsored_realm,
|
||||
make_end_of_cycle_updates_if_needed,
|
||||
process_initial_upgrade,
|
||||
renewal_amount,
|
||||
|
@ -190,7 +191,7 @@ def initial_upgrade(request: HttpRequest) -> HttpResponse:
|
|||
billing_page_url = f"{billing_page_url}?onboarding=true"
|
||||
return HttpResponseRedirect(billing_page_url)
|
||||
|
||||
if user.realm.plan_type == user.realm.STANDARD_FREE:
|
||||
if is_sponsored_realm(user.realm):
|
||||
return HttpResponseRedirect(billing_page_url)
|
||||
|
||||
percent_off = Decimal(0)
|
||||
|
|
Loading…
Reference in New Issue