support: Mention % in attach discount success message.

This commit is contained in:
Vishnu KS 2020-12-04 19:46:40 +05:30 committed by Tim Abbott
parent bd2642a7b8
commit 7b2f16bc5c
2 changed files with 3 additions and 4 deletions

View File

@ -646,7 +646,7 @@ class TestSupportEndpoint(ZulipTestCase):
with mock.patch("analytics.views.attach_discount_to_realm") as m: 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"}) result = self.client_post("/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"})
m.assert_called_once_with(get_realm("lear"), 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: def test_change_sponsorship_status(self) -> None:
lear_realm = get_realm("lear") lear_realm = get_realm("lear")

View File

@ -1136,10 +1136,9 @@ def support(request: HttpRequest) -> HttpResponse:
context["success_message"] = msg context["success_message"] = msg
elif request.POST.get("discount", None) is not None: elif request.POST.get("discount", None) is not None:
new_discount = Decimal(request.POST.get("discount")) 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) attach_discount_to_realm(realm, new_discount)
msg = f"Discount of {realm.string_id} changed to {new_discount} from {current_discount} " context["success_message"] = f"Discount of {realm.string_id} changed to {new_discount}% from {current_discount}%."
context["success_message"] = msg
elif request.POST.get("new_subdomain", None) is not None: elif request.POST.get("new_subdomain", None) is not None:
new_subdomain = request.POST.get("new_subdomain") new_subdomain = request.POST.get("new_subdomain")
old_subdomain = realm.string_id old_subdomain = realm.string_id