realm: Rename plan type constants to be more descriptive.

It is confusing to have the plan type constants not be namespaced
by the thing they represent. We already have a namespacing
convention in place for constants, so we should use it for
Realm.plan_type as well.
This commit is contained in:
Eeshan Garg
2021-10-18 17:28:17 -04:00
committed by Tim Abbott
parent cbbd4b128d
commit b325a4f1be
25 changed files with 141 additions and 131 deletions

View File

@@ -466,7 +466,7 @@ class TestSupportEndpoint(ZulipTestCase):
)
self.assert_in_success_response(["Sponsorship approved for lear"], result)
lear_realm.refresh_from_db()
self.assertEqual(lear_realm.plan_type, Realm.STANDARD_FREE)
self.assertEqual(lear_realm.plan_type, Realm.PLAN_TYPE_STANDARD_FREE)
customer = get_customer_by_realm(lear_realm)
assert customer is not None
self.assertFalse(customer.sponsorship_pending)

View File

@@ -223,11 +223,14 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
if string_id in estimated_arrs:
row["arr"] = estimated_arrs[string_id]
if row["plan_type"] in [Realm.STANDARD, Realm.PLUS]:
if row["plan_type"] in [Realm.PLAN_TYPE_STANDARD, Realm.PLAN_TYPE_PLUS]:
row["effective_rate"] = 100 - int(realms_to_default_discount.get(string_id, 0))
elif row["plan_type"] == Realm.STANDARD_FREE:
elif row["plan_type"] == Realm.PLAN_TYPE_STANDARD_FREE:
row["effective_rate"] = 0
elif row["plan_type"] == Realm.LIMITED and string_id in realms_to_default_discount:
elif (
row["plan_type"] == Realm.PLAN_TYPE_LIMITED
and string_id in realms_to_default_discount
):
row["effective_rate"] = 100 - int(realms_to_default_discount[string_id])
else:
row["effective_rate"] = ""

View File

@@ -59,11 +59,11 @@ if settings.BILLING_ENABLED:
def get_plan_name(plan_type: int) -> str:
return {
Realm.SELF_HOSTED: "self hosted",
Realm.LIMITED: "limited",
Realm.STANDARD: "standard",
Realm.STANDARD_FREE: "open source",
Realm.PLUS: "plus",
Realm.PLAN_TYPE_SELF_HOSTED: "self hosted",
Realm.PLAN_TYPE_LIMITED: "limited",
Realm.PLAN_TYPE_STANDARD: "standard",
Realm.PLAN_TYPE_STANDARD_FREE: "open source",
Realm.PLAN_TYPE_PLUS: "plus",
}[plan_type]