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: Use shared template for current plan details on support views.

Lauryn Menardd079a1376022
diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py
index 1ad13d6c38a..1c31d3f0570 100644
--- a/analytics/tests/test_support_views.py
+++ b/analytics/tests/test_support_views.py
@@ -198,7 +198,7 @@ class TestSupportEndpoint(ZulipTestCase):
'<option value="deactivated" >Deactivated</option>',
'scrub-realm-button">',
'data-string-id="lear"',
- "<b>Name</b>: Zulip Cloud Standard",
+ "<b>Plan name</b>: Zulip Cloud Standard",
"<b>Status</b>: Active",
"<b>Billing schedule</b>: Annual",
"<b>Licenses</b>: 2/10 (Manual)",
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index 4263ad4d08f..26775db2265 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -18,6 +18,7 @@ class PlanData:
current_plan: Optional["CustomerPlan"] = None
licenses: Optional[int] = None
licenses_used: Optional[int] = None
+ is_legacy_plan: bool = False
def get_support_url(realm: Realm) -> str:
@@ -55,5 +56,9 @@ def get_current_plan_data_for_support_view(billing_session: BillingSession) -> P
plan_data.current_plan = new_plan # nocoverage
plan_data.licenses = last_ledger_entry.licenses
plan_data.licenses_used = billing_session.current_count_for_billed_licenses()
+ assert plan_data.current_plan is not None # for mypy
+ plan_data.is_legacy_plan = (
+ plan_data.current_plan.tier == CustomerPlan.TIER_SELF_HOSTED_LEGACY
+ )
return plan_data
diff --git a/templates/analytics/current_plan_details.html b/templates/analytics/current_plan_details.html
new file mode 100644
index 00000000000..d123670915f
--- /dev/null
+++ b/templates/analytics/current_plan_details.html
@@ -0,0 +1,15 @@
+<h4>📅 Current plan information:</h4>
+<b>Plan name</b>: {{ plan_data.current_plan.name }}<br />
+<b>Status</b>: {{ plan_data.current_plan.get_plan_status_as_text() }}<br />
+{% if plan_data.is_legacy_plan %}
+ <b>End date</b>: {{ plan_data.current_plan.end_date.strftime('%d %B %Y') }}<br />
+{% else %}
+ <b>Billing schedule</b>: {% if plan_data.current_plan.billing_schedule == plan_data.current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %}<br />
+ <b>Licenses</b>: {{ plan_data.licenses_used }}/{{ plan_data.licenses }} ({% if plan_data.current_plan.automanage_licenses %}Automatic{% else %}Manual{% endif %})<br />
+ {% if plan_data.current_plan.price_per_license %}
+ <b>Price per license</b>: ${{ plan_data.current_plan.price_per_license/100 }}<br />
+ {% elif plan_data.current_plan.fixed_price %}
+ <b>Fixed price</b>: ${{ plan_data.current_plan.fixed_price/100 }}<br />
+ {% endif %}
+ <b>Next invoice date</b>: {{ plan_data.current_plan.next_invoice_date.strftime('%d %B %Y') }}<br />
+{% endif %}
diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.html
index a18e1d1224e..9cc589818b8 100644
--- a/templates/analytics/realm_details.html
+++ b/templates/analytics/realm_details.html
@@ -108,19 +108,13 @@
<button type="submit" class="btn btn-default support-submit-button">Update</button>
{% endif %}
</form>
+
{% if plan_data[realm.id].current_plan %}
<div class="current-plan-details">
- <h3>📅 Current plan</h3>
- <b>Name</b>: {{ plan_data[realm.id].current_plan.name }}<br />
- <b>Status</b>: {{plan_data[realm.id].current_plan.get_plan_status_as_text()}}<br />
- <b>Billing schedule</b>: {% if plan_data[realm.id].current_plan.billing_schedule == plan_data[realm.id].current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %}<br />
- <b>Licenses</b>: {{ plan_data[realm.id].licenses_used }}/{{ plan_data[realm.id].licenses }} ({% if plan_data[realm.id].current_plan.automanage_licenses %}Automatic{% else %}Manual{% endif %})<br />
- {% if plan_data[realm.id].current_plan.price_per_license %}
- <b>Price per license</b>: ${{ plan_data[realm.id].current_plan.price_per_license/100 }}<br />
- {% else %}
- <b>Fixed price</b>: ${{ plan_data[realm.id].current_plan.fixed_price/100 }}<br />
- {% endif %}
- <b>Next invoice date</b>: {{ plan_data[realm.id].current_plan.next_invoice_date.strftime('%d %B %Y') }}<br />
+ {% with %}
+ {% set plan_data = plan_data[realm.id] %}
+ {% include 'analytics/current_plan_details.html' %}
+ {% endwith %}
</div>
<form method="POST" class="billing-modality-form">
diff --git a/templates/analytics/remote_server_support.html b/templates/analytics/remote_server_support.html
index 1d95be10cf1..d03b42c4c73 100644
--- a/templates/analytics/remote_server_support.html
+++ b/templates/analytics/remote_server_support.html
@@ -93,21 +93,10 @@
{% if plan_data[remote_server.id].current_plan %}
<div class="remote-server-information">
- <h4>📅 Current plan information:</h4>
- <b>Plan name</b>: {{ plan_data[remote_server.id].current_plan.name }}<br />
- <b>Status</b>: {{plan_data[remote_server.id].current_plan.get_plan_status_as_text()}}<br />
- {% if plan_data[remote_server.id].current_plan.tier != 101 %}
- <b>Billing schedule</b>: {% if plan_data[remote_server.id].current_plan.billing_schedule == plan_data[remote_server.id].current_plan.BILLING_SCHEDULE_ANNUAL %}Annual{% else %}Monthly{% endif %}<br />
- <b>Licenses</b>: {{ plan_data[remote_server.id].licenses_used }}/{{ plan_data[remote_server.id].licenses }} ({% if plan_data[remote_server.id].current_plan.automanage_licenses %}Automatic{% else %}Manual{% endif %})<br />
- {% if plan_data[remote_server.id].current_plan.price_per_license %}
- <b>Price per license</b>: ${{ plan_data[remote_server.id].current_plan.price_per_license/100 }}<br />
- {% elif plan_data[remote_server.id].current_plan.fixed_price %}
- <b>Fixed price</b>: ${{ plan_data[remote_server.id].current_plan.fixed_price/100 }}<br />
- {% endif %}
- <b>Next invoice date</b>: {{ plan_data[remote_server.id].current_plan.next_invoice_date.strftime('%d %B %Y') }}<br />
- {% else %}
- <b>End date</b>: {{ plan_data[remote_server.id].current_plan.end_date.strftime('%d %B %Y') }}<br />
- {% endif %}
+ {% with %}
+ {% set plan_data = plan_data[remote_server.id] %}
+ {% include 'analytics/current_plan_details.html' %}
+ {% endwith %}
</div>
<form method="POST" class="remote-server-form">
diff --git a/web/styles/portico/activity.css b/web/styles/portico/activity.css
index 9d8d9eb4bf5..12e99c1bfe9 100644
--- a/web/styles/portico/activity.css
+++ b/web/styles/portico/activity.css
@@ -189,7 +189,7 @@ tr.admin td:first-child {
.current-plan-details {
position: relative;
- top: -15px;
+ top: -45px;
}
.approve-sponsorship-form {