support: Create separate template for remote sponsorship/discounts.

Creates a separate template for the forms related to sponsorship
and discounts on the remote support view.
This commit is contained in:
Lauryn Menard 2023-12-11 17:19:03 +01:00 committed by Tim Abbott
parent c2a76ccb3e
commit 2684c21cca
3 changed files with 45 additions and 39 deletions

View File

@ -53,42 +53,14 @@
</div>
{% if remote_server.plan_type != SPONSORED_PLAN_TYPE %}
<form method="POST" class="remote-server-form">
<b>Sponsorship pending</b>:<br />
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
<select name="sponsorship_pending">
<option value="true" {% if plan_data[remote_server.id].customer and plan_data[remote_server.id].customer.sponsorship_pending %}selected{% endif %}>Yes</option>
<option value="false" {% if not plan_data[remote_server.id].customer or not plan_data[remote_server.id].customer.sponsorship_pending %}selected{% endif %}>No</option>
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
{% endif %}
{% if plan_data[remote_server.id].customer and plan_data[remote_server.id].customer.sponsorship_pending %}
<form method="POST" class="">
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
<input type="hidden" name="approve_sponsorship" value="true" />
<button class="btn btn-default sea-green small approve-sponsorship-button">
Approve full sponsorship
</button>
</form>
{% endif %}
{% if remote_server.plan_type != SPONSORED_PLAN_TYPE %}
<form method="POST" class="remote-server-form">
<b>Discount</b>:<br />
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
{% if plan_data[remote_server.id].has_fixed_price %}
<input type="number" name="discount" value="{{ get_discount(plan_data[remote_server.id].customer) }}" disabled />
<button type="submit" class="btn btn-default support-submit-button" disabled>Update</button>
{% else %}
<input type="number" name="discount" value="{{ get_discount(plan_data[remote_server.id].customer) }}" required />
<button type="submit" class="btn btn-default support-submit-button">Update</button>
{% endif %}
</form>
{% with %}
{% set customer = remote_servers_plan_data[remote_server.id].customer %}
{% set remote_id = remote_server.id %}
{% set remote_type = "remote_server_id" %}
{% set has_fixed_price = remote_servers_plan_data[remote_server.id].has_fixed_price %}
{% set get_discount = get_discount %}
{% include 'analytics/sponsorship_forms_support.html' %}
{% endwith %}
{% endif %}
{% if plan_data[remote_server.id].current_plan %}
@ -99,7 +71,7 @@
{% endwith %}
</div>
<form method="POST" class="remote-server-form">
<form method="POST" class="remote-form">
<b>Billing collection method</b><br />
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
@ -110,7 +82,7 @@
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
<form method="POST" class="remote-server-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 }}" />

View File

@ -0,0 +1,34 @@
<form method="POST" class="remote-form">
<b>Sponsorship pending</b>:<br />
{{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
<select name="sponsorship_pending">
<option value="true" {% if customer and customer.sponsorship_pending %}selected{% endif %}>Yes</option>
<option value="false" {% if not customer or not customer.sponsorship_pending %}selected{% endif %}>No</option>
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
{% if customer and customer.sponsorship_pending %}
<form method="POST" class="">
{{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
<input type="hidden" name="approve_sponsorship" value="true" />
<button class="btn btn-default sea-green small approve-sponsorship-button">
Approve full sponsorship
</button>
</form>
{% endif %}
<form method="POST" class="remote-form">
<b>Discount</b>:<br />
{{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
{% if has_fixed_price %}
<input type="number" name="discount" value="{{ get_discount(customer) }}" disabled />
<button type="submit" class="btn btn-default support-submit-button" disabled>Update</button>
{% else %}
<input type="number" name="discount" value="{{ get_discount(customer) }}" required />
<button type="submit" class="btn btn-default support-submit-button">Update</button>
{% endif %}
</form>

View File

@ -158,7 +158,7 @@ tr.admin td:first-child {
padding-bottom: 15px;
}
.remote-server-form {
.remote-form {
margin-bottom: 10px;
}