mirror of https://github.com/zulip/zulip.git
billing: Add PLUS as a plan_type to Realm.
This commit is contained in:
parent
a86ab18a7b
commit
aff52722a7
|
@ -356,6 +356,15 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||||
["Plan type of zulip changed from self hosted to limited"], result
|
["Plan type of zulip changed from self hosted to limited"], result
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with mock.patch("analytics.views.support.do_change_plan_type") as m:
|
||||||
|
result = self.client_post(
|
||||||
|
"/activity/support", {"realm_id": f"{iago.realm_id}", "plan_type": "10"}
|
||||||
|
)
|
||||||
|
m.assert_called_once_with(get_realm("zulip"), 10, acting_user=iago)
|
||||||
|
self.assert_in_success_response(
|
||||||
|
["Plan type of zulip changed from self hosted to plus"], result
|
||||||
|
)
|
||||||
|
|
||||||
def test_change_org_type(self) -> None:
|
def test_change_org_type(self) -> None:
|
||||||
cordelia = self.example_user("cordelia")
|
cordelia = self.example_user("cordelia")
|
||||||
self.login_user(cordelia)
|
self.login_user(cordelia)
|
||||||
|
|
|
@ -223,7 +223,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
|
||||||
if string_id in estimated_arrs:
|
if string_id in estimated_arrs:
|
||||||
row["arr"] = estimated_arrs[string_id]
|
row["arr"] = estimated_arrs[string_id]
|
||||||
|
|
||||||
if row["plan_type"] == Realm.STANDARD:
|
if row["plan_type"] in [Realm.STANDARD, Realm.PLUS]:
|
||||||
row["effective_rate"] = 100 - int(realms_to_default_discount.get(string_id, 0))
|
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.STANDARD_FREE:
|
||||||
row["effective_rate"] = 0
|
row["effective_rate"] = 0
|
||||||
|
|
|
@ -58,7 +58,13 @@ if settings.BILLING_ENABLED:
|
||||||
|
|
||||||
|
|
||||||
def get_plan_name(plan_type: int) -> str:
|
def get_plan_name(plan_type: int) -> str:
|
||||||
return ["", "self hosted", "limited", "standard", "open source"][plan_type]
|
return {
|
||||||
|
Realm.SELF_HOSTED: "self hosted",
|
||||||
|
Realm.LIMITED: "limited",
|
||||||
|
Realm.STANDARD: "standard",
|
||||||
|
Realm.STANDARD_FREE: "open source",
|
||||||
|
Realm.PLUS: "plus",
|
||||||
|
}[plan_type]
|
||||||
|
|
||||||
|
|
||||||
def get_confirmations(
|
def get_confirmations(
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
<option value="2" {% if realm.plan_type == 2 %}selected{% endif %}>Limited</option>
|
<option value="2" {% if realm.plan_type == 2 %}selected{% endif %}>Limited</option>
|
||||||
<option value="3" {% if realm.plan_type == 3 %}selected{% endif %}>Standard</option>
|
<option value="3" {% if realm.plan_type == 3 %}selected{% endif %}>Standard</option>
|
||||||
<option value="4" {% if realm.plan_type == 4 %}selected{% endif %}>Standard Free</option>
|
<option value="4" {% if realm.plan_type == 4 %}selected{% endif %}>Standard Free</option>
|
||||||
|
<option value="10" {% if realm.plan_type == 10 %}selected{% endif %}>Plus</option>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" class="btn btn-default support-submit-button">Update</button>
|
<button type="submit" class="btn btn-default support-submit-button">Update</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -4625,7 +4625,11 @@ def do_change_plan_type(
|
||||||
extra_data={"old_value": old_value, "new_value": plan_type},
|
extra_data={"old_value": old_value, "new_value": plan_type},
|
||||||
)
|
)
|
||||||
|
|
||||||
if plan_type == Realm.STANDARD:
|
if plan_type == Realm.PLUS:
|
||||||
|
realm.max_invites = Realm.INVITES_STANDARD_REALM_DAILY_MAX
|
||||||
|
realm.message_visibility_limit = None
|
||||||
|
realm.upload_quota_gb = Realm.UPLOAD_QUOTA_STANDARD
|
||||||
|
elif plan_type == Realm.STANDARD:
|
||||||
realm.max_invites = Realm.INVITES_STANDARD_REALM_DAILY_MAX
|
realm.max_invites = Realm.INVITES_STANDARD_REALM_DAILY_MAX
|
||||||
realm.message_visibility_limit = None
|
realm.message_visibility_limit = None
|
||||||
realm.upload_quota_gb = Realm.UPLOAD_QUOTA_STANDARD
|
realm.upload_quota_gb = Realm.UPLOAD_QUOTA_STANDARD
|
||||||
|
|
|
@ -540,6 +540,7 @@ class Realm(models.Model):
|
||||||
LIMITED = 2
|
LIMITED = 2
|
||||||
STANDARD = 3
|
STANDARD = 3
|
||||||
STANDARD_FREE = 4
|
STANDARD_FREE = 4
|
||||||
|
PLUS = 10
|
||||||
plan_type: int = models.PositiveSmallIntegerField(default=SELF_HOSTED)
|
plan_type: int = models.PositiveSmallIntegerField(default=SELF_HOSTED)
|
||||||
|
|
||||||
# This value is also being used in static/js/settings_bots.bot_creation_policy_values.
|
# This value is also being used in static/js/settings_bots.bot_creation_policy_values.
|
||||||
|
|
|
@ -754,7 +754,16 @@ class HomeTest(ZulipTestCase):
|
||||||
self.assertTrue(billing_info.show_billing)
|
self.assertTrue(billing_info.show_billing)
|
||||||
self.assertFalse(billing_info.show_plans)
|
self.assertFalse(billing_info.show_plans)
|
||||||
|
|
||||||
|
# billing admin, with CustomerPlan and realm plan_type PLUS -> show only billing link
|
||||||
|
do_change_plan_type(user.realm, Realm.PLUS, acting_user=None)
|
||||||
|
user.save(update_fields=["role", "is_billing_admin"])
|
||||||
|
with self.settings(CORPORATE_ENABLED=True):
|
||||||
|
billing_info = get_billing_info(user)
|
||||||
|
self.assertTrue(billing_info.show_billing)
|
||||||
|
self.assertFalse(billing_info.show_plans)
|
||||||
|
|
||||||
# member, with CustomerPlan and realm plan_type STANDARD -> neither billing link or plans
|
# member, with CustomerPlan and realm plan_type STANDARD -> neither billing link or plans
|
||||||
|
do_change_plan_type(user.realm, Realm.STANDARD, acting_user=None)
|
||||||
user.is_billing_admin = False
|
user.is_billing_admin = False
|
||||||
user.save(update_fields=["is_billing_admin"])
|
user.save(update_fields=["is_billing_admin"])
|
||||||
with self.settings(CORPORATE_ENABLED=True):
|
with self.settings(CORPORATE_ENABLED=True):
|
||||||
|
|
|
@ -699,6 +699,12 @@ class RealmTest(ZulipTestCase):
|
||||||
self.assertEqual(realm.upload_quota_gb, Realm.UPLOAD_QUOTA_STANDARD)
|
self.assertEqual(realm.upload_quota_gb, Realm.UPLOAD_QUOTA_STANDARD)
|
||||||
|
|
||||||
do_change_plan_type(realm, Realm.LIMITED, acting_user=iago)
|
do_change_plan_type(realm, Realm.LIMITED, acting_user=iago)
|
||||||
|
do_change_plan_type(realm, Realm.PLUS, acting_user=iago)
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
self.assertEqual(realm.plan_type, Realm.PLUS)
|
||||||
|
self.assertEqual(realm.max_invites, Realm.INVITES_STANDARD_REALM_DAILY_MAX)
|
||||||
|
self.assertEqual(realm.message_visibility_limit, None)
|
||||||
|
self.assertEqual(realm.upload_quota_gb, Realm.UPLOAD_QUOTA_STANDARD)
|
||||||
|
|
||||||
do_change_plan_type(realm, Realm.SELF_HOSTED, acting_user=iago)
|
do_change_plan_type(realm, Realm.SELF_HOSTED, acting_user=iago)
|
||||||
self.assertEqual(realm.plan_type, Realm.SELF_HOSTED)
|
self.assertEqual(realm.plan_type, Realm.SELF_HOSTED)
|
||||||
|
|
Loading…
Reference in New Issue