support: Always show the option to update end_date on /support page.

If a plan is already on "basic" or "business" plan and wants to
switch to a fixed-price "basic" / "business" plan, then it is
necessary that the current plan should have an end date configured.

Earlier, we could update the end_date only if the current plan
already had an end_date set.

This commit makes it possible to always show the option to
set or update end_date.
This commit is contained in:
Prakhar Pratyush 2024-01-30 17:31:33 +05:30 committed by Tim Abbott
parent 928de1a74b
commit 26536a20ed
2 changed files with 3 additions and 3 deletions

View File

@ -1312,7 +1312,6 @@ class BillingSession(ABC):
if customer is not None: if customer is not None:
plan = get_current_plan_by_customer(customer) plan = get_current_plan_by_customer(customer)
if plan is not None: if plan is not None:
assert plan.end_date is not None
assert plan.status == CustomerPlan.ACTIVE assert plan.status == CustomerPlan.ACTIVE
old_end_date = plan.end_date old_end_date = plan.end_date
plan.end_date = new_end_date plan.end_date = new_end_date

View File

@ -9,12 +9,13 @@
<button type="submit" class="support-submit-button">Update</button> <button type="submit" class="support-submit-button">Update</button>
</form> </form>
{% if current_plan.end_date and current_plan.status == current_plan.ACTIVE %} {% if current_plan.status == current_plan.ACTIVE %}
<form method="POST" class="remote-form"> <form method="POST" class="remote-form">
<b>Plan end date</b><br /> <b>Plan end date</b><br />
{{ csrf_input }} {{ csrf_input }}
<input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" /> <input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
<input type="date" name="plan_end_date" value="{{ current_plan.end_date.strftime('%Y-%m-%d') }}" required /> <input type="date" name="plan_end_date" {% if current_plan.end_date %}
value="{{ current_plan.end_date.strftime('%Y-%m-%d') }}" {% endif %} required />
<button type="submit" class="support-submit-button">Update</button> <button type="submit" class="support-submit-button">Update</button>
</form> </form>
{% endif %} {% endif %}