support: Show discount information on remote support views.

In commit 7203661d99, we removed the default_discount field on the
Customer model, but we didn't update the remote support views for
this change.

Adds a has_discount boolean to the SponsorshipData that's used in
the support views for headers, and updates the discount information
on a deactivated remote realm to show any pre-existing discounted
prices.
This commit is contained in:
Lauryn Menard 2024-08-07 20:53:08 +02:00 committed by Tim Abbott
parent fc2ce3deb2
commit 391c52639f
4 changed files with 16 additions and 5 deletions

View File

@ -58,6 +58,7 @@ class SponsorshipRequestDict(TypedDict):
@dataclass
class SponsorshipData:
sponsorship_pending: bool = False
has_discount: bool = False
monthly_discounted_price: int | None = None
annual_discounted_price: int | None = None
original_monthly_plan_price: int | None = None
@ -132,14 +133,17 @@ def get_customer_sponsorship_data(customer: Customer) -> SponsorshipData:
pending = customer.sponsorship_pending
licenses = customer.minimum_licenses
plan_tier = customer.required_plan_tier
has_discount = False
sponsorship_request = None
monthly_discounted_price = None
annual_discounted_price = None
original_monthly_plan_price = None
original_annual_plan_price = None
if customer.monthly_discounted_price:
has_discount = True
monthly_discounted_price = customer.monthly_discounted_price
if customer.annual_discounted_price:
has_discount = True
annual_discounted_price = customer.annual_discounted_price
if plan_tier is not None:
original_monthly_plan_price = get_price_per_license(
@ -173,6 +177,7 @@ def get_customer_sponsorship_data(customer: Customer) -> SponsorshipData:
return SponsorshipData(
sponsorship_pending=pending,
has_discount=has_discount,
monthly_discounted_price=monthly_discounted_price,
annual_discounted_price=annual_discounted_price,
original_monthly_plan_price=original_monthly_plan_price,

View File

@ -14,7 +14,7 @@
{% if remote_realm.plan_type == SPONSORED_PLAN_TYPE %}
<p class="support-section-header">On 100% sponsored Zulip Community plan 🎉</p>
{% endif %}
{% if support_data[remote_realm.id].sponsorship_data.default_discount %}
{% if support_data[remote_realm.id].sponsorship_data.has_discount %}
<p class="support-section-header">Has a discount 💸</p>
{% endif %}
<b>Remote realm host:</b> {{ remote_realm.host }}<br />
@ -48,6 +48,7 @@
<div class="remote-support-sponsorship-container">
{% with %}
{% set sponsorship_data = support_data[remote_realm.id].sponsorship_data %}
{% set dollar_amount = dollar_amount %}
{% include 'corporate/support/sponsorship_details.html' %}
{% endwith %}
</div>

View File

@ -46,7 +46,7 @@
{% if remote_server.plan_type == SPONSORED_PLAN_TYPE %}
<p class="support-section-header">On 100% sponsored Zulip Community plan 🎉</p>
{% endif %}
{% if remote_servers_support_data[remote_server.id].sponsorship_data.default_discount %}
{% if remote_servers_support_data[remote_server.id].sponsorship_data.has_discount %}
<p class="support-section-header">Has a discount 💸</p>
{% endif %}
<b>Contact email</b>: {{ remote_server.contact_email }}

View File

@ -1,10 +1,15 @@
<div class="remote-sponsorship-details">
<p class="support-section-header">💸 Discount and sponsorship information:</p>
<b>Sponsorship pending</b>: {{ sponsorship_data.sponsorship_pending }}<br />
{% if sponsorship_data.default_discount %}
<b>Discount</b>: {{ sponsorship_data.default_discount }}%<br />
{% if sponsorship_data.has_discount %}
{% if sponsorship_data.monthly_discounted_price %}
<b>Discounted price (monthly)</b>: {{ dollar_amount(sponsorship_data.monthly_discounted_price) }}%<br />
{% endif %}
{% if sponsorship_data.annual_discounted_price %}
<b>Discounted price (annual)</b>: {{ dollar_amount(sponsorship_data.monthly_discounted_price) }}%<br />
{% endif %}
{% else %}
<b>Discount</b>: None<br />
<b>Discounted price</b>: None<br />
{% endif %}
<b>Minimum licenses</b>: {{ sponsorship_data.minimum_licenses }}<br />
{% if sponsorship_data.required_plan_tier %}