support: Pass remote_support_view boolean in context for views.

Many of the templates for the remote and Cloud support views are
designed to be shared, but some features/actions have not yet been
implemented for both types of support views.

Adds a remote_support_view boolean to each type of support view
context so that it's easy to add checks to existing templates.

Updates the Cloud support view to use the current_plan_forms_support
template, and fixes existing bug of offering the upgrade to Plus
option for modifying a Cloud plan when the current plan is a
fixed-price plan.

Prep for implementing fixed-price plan offers in Cloud support view.
This commit is contained in:
Lauryn Menard
2024-11-21 18:36:18 +01:00
committed by Tim Abbott
parent 746268e878
commit 84dddbd496
4 changed files with 13 additions and 26 deletions

View File

@@ -671,6 +671,7 @@ def support(
context["ORGANIZATION_TYPES"] = sorted(
Realm.ORG_TYPES.values(), key=lambda d: d["display_order"]
)
context["remote_support_view"] = False
return render(request, "corporate/support/support.html", context=context)
@@ -957,6 +958,7 @@ def remote_servers_support(
)
context["get_remote_realm_billing_user_emails"] = get_remote_realm_billing_user_emails_as_string
context["SPONSORED_PLAN_TYPE"] = RemoteZulipServer.PLAN_TYPE_COMMUNITY
context["remote_support_view"] = True
return render(
request,

View File

@@ -9,7 +9,7 @@
<button type="submit" class="support-submit-button">Update</button>
</form>
{% if current_plan.status == current_plan.ACTIVE %}
{% if current_plan.status == current_plan.ACTIVE and remote_support_view %}
<form method="POST" class="support-form">
<b>Plan end date</b><br />
{{ csrf_input }}
@@ -29,6 +29,9 @@
<option value="downgrade_at_billing_cycle_end">Downgrade at the end of current billing cycle</option>
<option value="downgrade_now_without_additional_licenses">Downgrade now without creating additional invoices</option>
<option value="downgrade_now_void_open_invoices">Downgrade now and void open invoices</option>
{% if not remote_support_view and not current_plan.fixed_price %}
<option value="upgrade_plan_tier">Upgrade to the Plus plan</option>
{% endif %}
</select>
<button type="submit" class="support-submit-button">Modify</button>
</form>

View File

@@ -12,7 +12,7 @@
{% endif %}
<button type="submit" class="support-submit-button">Schedule</button>
</form>
{% if not plan_data.current_plan %}
{% if not plan_data.current_plan and remote_support_view %}
<form method="POST" class="support-form">
<b>Configure temporary courtesy plan:</b><br />
<i>Once created, the end date for the temporary courtesy plan can be extended.</i><br />

View File

@@ -126,30 +126,12 @@
{% include 'corporate/support/current_plan_details.html' %}
{% endwith %}
<form method="POST" class="support-form">
<b>Billing collection method</b><br />
{{ csrf_input }}
<input type="hidden" name="realm_id" value="{{ realm.id }}" />
<select name="billing_modality" class="billing-modality-select" required>
<option value="charge_automatically" {% if realm_support_data[realm.id].plan_data.current_plan.charge_automatically %}selected{% endif %}>Charge automatically</option>
<option value="send_invoice" {% if not realm_support_data[realm.id].plan_data.current_plan.charge_automatically %}selected{% endif %}>Pay by invoice</option>
</select>
<button type="submit" class="support-submit-button">Update</button>
</form>
<form method="POST" class="support-form">
<b>Modify plan</b><br />
{{ csrf_input }}
<input type="hidden" name="realm_id" value="{{ realm.id }}" />
<select name="modify_plan" class="modify-plan-method-select" required>
<option disabled value="" selected>-- select --</option>
<option value="downgrade_at_billing_cycle_end">Downgrade at the end of current billing cycle</option>
<option value="downgrade_now_without_additional_licenses">Downgrade now without creating additional invoices</option>
<option value="downgrade_now_void_open_invoices">Downgrade now and void open invoices</option>
<option value="upgrade_plan_tier">Upgrade to the Plus plan</option>
</select>
<button type="submit" class="support-submit-button">Modify</button>
</form>
{% with %}
{% set current_plan = realm_support_data[realm.id].plan_data.current_plan %}
{% set remote_id = realm.id %}
{% set remote_type = "realm_id" %}
{% include 'corporate/support/current_plan_forms_support.html' %}
{% endwith %}
</div>
{% endif %}