diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py index dda07163af..17d26b1390 100644 --- a/analytics/tests/test_support_views.py +++ b/analytics/tests/test_support_views.py @@ -667,6 +667,17 @@ class TestSupportEndpoint(ZulipTestCase): ["zulip downgraded and voided 1 open invoices"], result ) + with mock.patch("analytics.views.support.switch_realm_from_standard_to_plus_plan") as m: + result = self.client_post( + "/activity/support", + { + "realm_id": f"{iago.realm_id}", + "modify_plan": "upgrade_to_plus", + }, + ) + m.assert_called_once_with(get_realm("zulip")) + self.assert_in_success_response(["zulip upgraded to Plus"], result) + def test_scrub_realm(self) -> None: cordelia = self.example_user("cordelia") lear_realm = get_realm("lear") diff --git a/analytics/views/support.py b/analytics/views/support.py index 37f01efd83..4b88eefb37 100644 --- a/analytics/views/support.py +++ b/analytics/views/support.py @@ -54,6 +54,7 @@ if settings.BILLING_ENABLED: get_discount_for_realm, get_latest_seat_count, make_end_of_cycle_updates_if_needed, + switch_realm_from_standard_to_plus_plan, update_billing_method_of_current_plan, update_sponsorship_status, void_all_open_invoices, @@ -125,6 +126,7 @@ VALID_MODIFY_PLAN_METHODS = [ "downgrade_at_billing_cycle_end", "downgrade_now_without_additional_licenses", "downgrade_now_void_open_invoices", + "upgrade_to_plus", ] VALID_STATUS_VALUES = [ @@ -268,6 +270,9 @@ def support( context[ "success_message" ] = f"{realm.string_id} downgraded and voided {voided_invoices_count} open invoices" + elif modify_plan == "upgrade_to_plus": + switch_realm_from_standard_to_plus_plan(realm) + context["success_message"] = f"{realm.string_id} upgraded to Plus" elif scrub_realm: do_scrub_realm(realm, acting_user=acting_user) context["success_message"] = f"{realm.string_id} scrubbed." diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.html index ac7f246737..36c1ee7f73 100644 --- a/templates/analytics/realm_details.html +++ b/templates/analytics/realm_details.html @@ -145,6 +145,7 @@ +