Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

support: Mention % in attach discount success message.

Vishnu KS7b2f16bc5c75
diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py
index 2fed3edbe5f..367045e71e3 100644
--- a/analytics/tests/test_views.py
+++ b/analytics/tests/test_views.py
@@ -646,7 +646,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 changed to 25 from None"], result)
+ self.assert_in_success_response(["Discount of lear changed to 25% from 0%"], result)
def test_change_sponsorship_status(self) -> None:
lear_realm = get_realm("lear")
diff --git a/analytics/views.py b/analytics/views.py
index a1187023576..849d2e42712 100644
--- a/analytics/views.py
+++ b/analytics/views.py
@@ -1136,10 +1136,9 @@ def support(request: HttpRequest) -> HttpResponse:
context["success_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)
+ current_discount = get_discount_for_realm(realm) or 0
attach_discount_to_realm(realm, new_discount)
- msg = f"Discount of {realm.string_id} changed to {new_discount} from {current_discount} "
- context["success_message"] = msg
+ context["success_message"] = f"Discount of {realm.string_id} changed to {new_discount}% from {current_discount}%."
elif request.POST.get("new_subdomain", None) is not None:
new_subdomain = request.POST.get("new_subdomain")
old_subdomain = realm.string_id