mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
support: Show current discount for current plan.
This should match any discount information shown for the remote realm or server.
This commit is contained in:
committed by
Tim Abbott
parent
be6c90f608
commit
a8172591ca
@@ -615,10 +615,11 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||
)
|
||||
|
||||
def test_attach_discount(self) -> None:
|
||||
cordelia = self.example_user("cordelia")
|
||||
lear_realm = get_realm("lear")
|
||||
self.login_user(cordelia)
|
||||
customer = self.create_customer_and_plan(lear_realm, True)
|
||||
|
||||
cordelia = self.example_user("cordelia")
|
||||
self.login_user(cordelia)
|
||||
result = self.client_post(
|
||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"}
|
||||
)
|
||||
@@ -632,9 +633,26 @@ class TestSupportEndpoint(ZulipTestCase):
|
||||
"/activity/support", {"realm_id": f"{lear_realm.id}", "discount": "25"}
|
||||
)
|
||||
self.assert_in_success_response(["Discount for lear changed to 25% from 0%"], result)
|
||||
customer = get_customer_by_realm(lear_realm)
|
||||
assert customer is not None
|
||||
|
||||
customer.refresh_from_db()
|
||||
plan = get_current_plan_by_customer(customer)
|
||||
assert plan is not None
|
||||
self.assertEqual(customer.default_discount, Decimal(25))
|
||||
self.assertEqual(plan.discount, Decimal(25))
|
||||
|
||||
result = self.client_get("/activity/support", {"q": "lear"})
|
||||
self.assert_in_success_response(
|
||||
[
|
||||
"<b>Plan name</b>: Zulip Cloud Standard",
|
||||
"<b>Status</b>: Active",
|
||||
"<b>Discount</b>: 25%",
|
||||
"<b>Billing schedule</b>: Monthly",
|
||||
"<b>Licenses</b>: 2/10 (Manual)",
|
||||
"<b>Price per license</b>: $6.0",
|
||||
"<b>Next invoice date</b>: 02 February 2016",
|
||||
],
|
||||
result,
|
||||
)
|
||||
|
||||
def test_change_sponsorship_status(self) -> None:
|
||||
lear_realm = get_realm("lear")
|
||||
|
@@ -56,6 +56,7 @@ if settings.BILLING_ENABLED:
|
||||
RemoteServerBillingSession,
|
||||
SupportType,
|
||||
SupportViewRequest,
|
||||
format_discount_percentage,
|
||||
)
|
||||
from corporate.lib.support import (
|
||||
PlanData,
|
||||
@@ -364,6 +365,7 @@ def support(
|
||||
context["get_realm_admin_emails_as_string"] = get_realm_admin_emails_as_string
|
||||
context["get_discount"] = get_customer_discount_for_support_view
|
||||
context["get_org_type_display_name"] = get_org_type_display_name
|
||||
context["format_discount"] = format_discount_percentage
|
||||
context["realm_icon_url"] = realm_icon_url
|
||||
context["Confirmation"] = Confirmation
|
||||
context["sorted_realm_types"] = sorted(
|
||||
@@ -513,6 +515,7 @@ def remote_servers_support(
|
||||
context["remote_realms_support_data"] = realm_support_data
|
||||
context["get_plan_type_name"] = get_plan_type_string
|
||||
context["get_org_type_display_name"] = get_org_type_display_name
|
||||
context["format_discount"] = format_discount_percentage
|
||||
context["SPONSORED_PLAN_TYPE"] = RemoteZulipServer.PLAN_TYPE_COMMUNITY
|
||||
|
||||
return render(
|
||||
|
@@ -10,6 +10,9 @@
|
||||
{% if plan_data.current_plan.tier == plan_data.current_plan.TIER_SELF_HOSTED_COMMUNITY %}
|
||||
<!-- Any data below doesn't makes sense for sponsored organizations. -->
|
||||
{% else %}
|
||||
{% if plan_data.current_plan.discount %}
|
||||
<b>Discount</b>: {{ format_discount(plan_data.current_plan.discount) }}%<br />
|
||||
{% endif %}
|
||||
{% if plan_data.is_legacy_plan %}
|
||||
<b>End date</b>: {{ plan_data.current_plan.end_date.strftime('%d %B %Y') }}<br />
|
||||
{% else %}
|
||||
|
@@ -113,6 +113,7 @@
|
||||
<div class="current-plan-details">
|
||||
{% with %}
|
||||
{% set plan_data = plan_data[realm.id] %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include 'analytics/current_plan_details.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
@@ -27,6 +27,7 @@
|
||||
<div class="remote-realm-information">
|
||||
{% with %}
|
||||
{% set plan_data = support_data[remote_realm.id].plan_data %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include 'analytics/current_plan_details.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
@@ -69,6 +69,7 @@
|
||||
<div class="remote-server-information">
|
||||
{% with %}
|
||||
{% set plan_data = remote_servers_support_data[remote_server.id].plan_data %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include 'analytics/current_plan_details.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
@@ -87,6 +88,7 @@
|
||||
{% with %}
|
||||
{% set support_data = remote_realms_support_data %}
|
||||
{% set get_plan_type_name = get_plan_type_name %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include "analytics/remote_realm_details.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
@@ -49,7 +49,10 @@
|
||||
</form>
|
||||
<hr />
|
||||
<div>
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% with %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
@@ -57,7 +60,10 @@
|
||||
|
||||
{% for realm in realms %}
|
||||
<div class="support-query-result">
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% with %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -106,7 +112,10 @@
|
||||
{% if show_realm_details %}
|
||||
<hr />
|
||||
<div>
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% with %}
|
||||
{% set format_discount = format_discount %}
|
||||
{% include "analytics/realm_details.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% elif realm %}
|
||||
<b>Realm</b>: {{ realm.string_id }}
|
||||
|
Reference in New Issue
Block a user