support: Add forms for current plan actions to remote realms.

Pulls the forms for updating the billing collection method and
generally modifying the current plan to a separate template.

Uses the shared template to render these forms for both the
remote server and any attached remote realms.
This commit is contained in:
Lauryn Menard 2023-12-11 17:52:10 +01:00 committed by Tim Abbott
parent 6f3e1cf653
commit 144b2a9988
3 changed files with 36 additions and 23 deletions

View File

@ -0,0 +1,23 @@
<form method="POST" class="remote-form">
<b>Billing collection method</b><br />
{{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
<select name="billing_modality" class="billing-modality-select" required>
<option value="charge_automatically" {% if current_plan.charge_automatically %}selected{% endif %}>Charge automatically</option>
<option value="send_invoice" {% if not current_plan.charge_automatically %}selected{% endif %}>Pay by invoice</option>
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
<form method="POST" class="remote-form">
<b>Modify current plan</b><br />
{{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_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>
</select>
<button type="submit" class="btn btn-default support-submit-button">Modify</button>
</form>

View File

@ -27,4 +27,11 @@
{% include 'analytics/current_plan_details.html' %} {% include 'analytics/current_plan_details.html' %}
{% endwith %} {% endwith %}
</div> </div>
{% with %}
{% set current_plan = plan_data[remote_server.id].current_plan %}
{% set remote_id = remote_realm.id %}
{% set remote_type = "remote_realm_id" %}
{% include 'analytics/current_plan_forms_support.html' %}
{% endwith %}
{% endif %} {% endif %}

View File

@ -71,29 +71,12 @@
{% endwith %} {% endwith %}
</div> </div>
<form method="POST" class="remote-form"> {% with %}
<b>Billing collection method</b><br /> {% set current_plan = remote_servers_plan_data[remote_server.id].current_plan %}
{{ csrf_input }} {% set remote_id = remote_server.id %}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" /> {% set remote_type = "remote_server_id" %}
<select name="billing_modality" class="billing-modality-select" required> {% include 'analytics/current_plan_forms_support.html' %}
<option value="charge_automatically" {% if remote_servers_plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Charge automatically</option> {% endwith %}
<option value="send_invoice" {% if not remote_servers_plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Pay by invoice</option>
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
<form method="POST" class="remote-form">
<b>Modify current plan</b><br />
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.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>
</select>
<button type="submit" class="btn btn-default support-submit-button">Modify</button>
</form>
{% endif %} {% endif %}
{% for remote_realm in remote_realms[remote_server.id] %} {% for remote_realm in remote_realms[remote_server.id] %}