diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py index 3e14a9c05c..8445a4a5b6 100644 --- a/analytics/tests/test_views.py +++ b/analytics/tests/test_views.py @@ -587,13 +587,13 @@ class TestSupportEndpoint(ZulipTestCase): result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "billing_method": "charge_automatically"}) m.assert_called_once_with(get_realm("zulip"), charge_automatically=True) - self.assert_in_success_response(["Billing method of Zulip Dev updated to charge automatically"], result) + self.assert_in_success_response(["Billing method of zulip updated to charge automatically"], result) m.reset_mock() result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "billing_method": "send_invoice"}) m.assert_called_once_with(get_realm("zulip"), charge_automatically=False) - self.assert_in_success_response(["Billing method of Zulip Dev updated to pay by invoice"], result) + self.assert_in_success_response(["Billing method of zulip updated to pay by invoice"], result) def test_change_plan_type(self) -> None: cordelia = self.example_user('cordelia') @@ -609,7 +609,7 @@ class TestSupportEndpoint(ZulipTestCase): with mock.patch("analytics.views.do_change_plan_type") as m: result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "plan_type": "2"}) m.assert_called_once_with(get_realm("zulip"), 2) - self.assert_in_success_response(["Plan type of Zulip Dev changed from self hosted to limited"], result) + self.assert_in_success_response(["Plan type of zulip changed from self hosted to limited"], result) def test_attach_discount(self) -> None: cordelia = self.example_user('cordelia') @@ -625,7 +625,7 @@ class TestSupportEndpoint(ZulipTestCase): with mock.patch("analytics.views.attach_discount_to_realm") as m: result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"}) m.assert_called_once_with(get_realm("lear"), 25) - self.assert_in_success_response(["Discount of Lear & Co. changed to 25 from None"], result) + self.assert_in_success_response(["Discount of lear changed to 25 from None"], result) def test_change_sponsorship_status(self) -> None: lear_realm = get_realm("lear") @@ -644,14 +644,14 @@ class TestSupportEndpoint(ZulipTestCase): result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "sponsorship_pending": "true"}) - self.assert_in_success_response(["Lear & Co. marked as pending sponsorship."], result) + self.assert_in_success_response(["lear marked as pending sponsorship."], result) customer = get_customer_by_realm(lear_realm) assert(customer is not None) self.assertTrue(customer.sponsorship_pending) result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "sponsorship_pending": "false"}) - self.assert_in_success_response(["Lear & Co. is no longer pending sponsorship."], result) + self.assert_in_success_response(["lear is no longer pending sponsorship."], result) customer = get_customer_by_realm(lear_realm) assert(customer is not None) self.assertFalse(customer.sponsorship_pending) @@ -676,7 +676,7 @@ class TestSupportEndpoint(ZulipTestCase): result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "approve_sponsorship": "approve_sponsorship"}) - self.assert_in_success_response(["Sponsorship approved for Lear & Co."], result) + self.assert_in_success_response(["Sponsorship approved for lear"], result) lear_realm.refresh_from_db() self.assertEqual(lear_realm.plan_type, Realm.STANDARD_FREE) customer = get_customer_by_realm(lear_realm) @@ -700,12 +700,12 @@ class TestSupportEndpoint(ZulipTestCase): with mock.patch("analytics.views.do_deactivate_realm") as m: result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "status": "deactivated"}) m.assert_called_once_with(lear_realm, self.example_user("iago")) - self.assert_in_success_response(["Lear & Co. deactivated"], result) + self.assert_in_success_response(["lear deactivated"], result) with mock.patch("analytics.views.do_send_realm_reactivation_email") as m: result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "status": "active"}) m.assert_called_once_with(lear_realm) - self.assert_in_success_response(["Realm reactivation email sent to admins of Lear"], result) + self.assert_in_success_response(["Realm reactivation email sent to admins of lear"], result) def test_downgrade_realm(self) -> None: cordelia = self.example_user('cordelia') @@ -721,13 +721,13 @@ class TestSupportEndpoint(ZulipTestCase): result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "downgrade_method": "downgrade_at_billing_cycle_end"}) m.assert_called_once_with(get_realm("zulip")) - self.assert_in_success_response(["Zulip Dev marked for downgrade at the end of billing cycle"], result) + self.assert_in_success_response(["zulip marked for downgrade at the end of billing cycle"], result) with mock.patch("analytics.views.downgrade_now_without_creating_additional_invoices") as m: result = self.client_post("/activity/support", {"realm_id": f"{iago.realm_id}", "downgrade_method": "downgrade_now_without_additional_licenses"}) m.assert_called_once_with(get_realm("zulip")) - self.assert_in_success_response(["Zulip Dev downgraded without creating additional invoices"], result) + self.assert_in_success_response(["zulip downgraded without creating additional invoices"], result) with mock.patch("analytics.views.downgrade_now_without_creating_additional_invoices") as m1: with mock.patch("analytics.views.void_all_open_invoices", return_value=1) as m2: @@ -735,7 +735,7 @@ class TestSupportEndpoint(ZulipTestCase): "downgrade_method": "downgrade_now_void_open_invoices"}) m1.assert_called_once_with(get_realm("zulip")) m2.assert_called_once_with(get_realm("zulip")) - self.assert_in_success_response(["Zulip Dev downgraded and voided 1 open invoices"], result) + self.assert_in_success_response(["zulip downgraded and voided 1 open invoices"], result) def test_scrub_realm(self) -> None: cordelia = self.example_user('cordelia') @@ -751,7 +751,7 @@ class TestSupportEndpoint(ZulipTestCase): with mock.patch("analytics.views.do_scrub_realm") as m: result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "scrub_realm": "scrub_realm"}) m.assert_called_once_with(lear_realm, acting_user=self.example_user("iago")) - self.assert_in_success_response(["Lear & Co. scrubbed"], result) + self.assert_in_success_response(["lear scrubbed"], result) with mock.patch("analytics.views.do_scrub_realm") as m: result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}"}) diff --git a/analytics/views.py b/analytics/views.py index 2a9ca21f3d..5a9fd24fff 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -1159,58 +1159,58 @@ def support(request: HttpRequest) -> HttpResponse: new_plan_type = int(request.POST.get("plan_type")) current_plan_type = realm.plan_type do_change_plan_type(realm, new_plan_type) - msg = f"Plan type of {realm.name} changed from {get_plan_name(current_plan_type)} to {get_plan_name(new_plan_type)} " + msg = f"Plan type of {realm.string_id} changed from {get_plan_name(current_plan_type)} to {get_plan_name(new_plan_type)} " context["message"] = msg elif request.POST.get("discount", None) is not None: new_discount = Decimal(request.POST.get("discount")) current_discount = get_discount_for_realm(realm) attach_discount_to_realm(realm, new_discount) - msg = f"Discount of {realm.name} changed to {new_discount} from {current_discount} " + msg = f"Discount of {realm.string_id} changed to {new_discount} from {current_discount} " context["message"] = msg elif request.POST.get("status", None) is not None: status = request.POST.get("status") if status == "active": do_send_realm_reactivation_email(realm) - context["message"] = f"Realm reactivation email sent to admins of {realm.name}." + context["message"] = f"Realm reactivation email sent to admins of {realm.string_id}." elif status == "deactivated": do_deactivate_realm(realm, request.user) - context["message"] = f"{realm.name} deactivated." + context["message"] = f"{realm.string_id} deactivated." elif request.POST.get("billing_method", None) is not None: billing_method = request.POST.get("billing_method") if billing_method == "send_invoice": update_billing_method_of_current_plan(realm, charge_automatically=False) - context["message"] = f"Billing method of {realm.name} updated to pay by invoice." + context["message"] = f"Billing method of {realm.string_id} updated to pay by invoice." elif billing_method == "charge_automatically": update_billing_method_of_current_plan(realm, charge_automatically=True) - context["message"] = f"Billing method of {realm.name} updated to charge automatically." + context["message"] = f"Billing method of {realm.string_id} updated to charge automatically." elif request.POST.get("sponsorship_pending", None) is not None: sponsorship_pending = request.POST.get("sponsorship_pending") if sponsorship_pending == "true": update_sponsorship_status(realm, True) - context["message"] = f"{realm.name} marked as pending sponsorship." + context["message"] = f"{realm.string_id} marked as pending sponsorship." elif sponsorship_pending == "false": update_sponsorship_status(realm, False) - context["message"] = f"{realm.name} is no longer pending sponsorship." + context["message"] = f"{realm.string_id} is no longer pending sponsorship." elif request.POST.get('approve_sponsorship') is not None: if request.POST.get('approve_sponsorship') == "approve_sponsorship": approve_sponsorship(realm) - context["message"] = f"Sponsorship approved for {realm.name}" + context["message"] = f"Sponsorship approved for {realm.string_id}" elif request.POST.get('downgrade_method', None) is not None: downgrade_method = request.POST.get('downgrade_method') if downgrade_method == "downgrade_at_billing_cycle_end": downgrade_at_the_end_of_billing_cycle(realm) - context["message"] = f"{realm.name} marked for downgrade at the end of billing cycle" + context["message"] = f"{realm.string_id} marked for downgrade at the end of billing cycle" elif downgrade_method == "downgrade_now_without_additional_licenses": downgrade_now_without_creating_additional_invoices(realm) - context["message"] = f"{realm.name} downgraded without creating additional invoices" + context["message"] = f"{realm.string_id} downgraded without creating additional invoices" elif downgrade_method == "downgrade_now_void_open_invoices": downgrade_now_without_creating_additional_invoices(realm) voided_invoices_count = void_all_open_invoices(realm) - context["message"] = f"{realm.name} downgraded and voided {voided_invoices_count} open invoices" + context["message"] = f"{realm.string_id} downgraded and voided {voided_invoices_count} open invoices" elif request.POST.get("scrub_realm", None) is not None: if request.POST.get("scrub_realm") == "scrub_realm": do_scrub_realm(realm, acting_user=request.user) - context["message"] = f"{realm.name} scrubbed." + context["message"] = f"{realm.string_id} scrubbed." query = request.GET.get("q", None) if query: