mirror of https://github.com/zulip/zulip.git
billing: Allow legacy servers to cancel upgrade.
This commit is contained in:
parent
00b7424d11
commit
825986ac3a
|
@ -1869,7 +1869,14 @@ class BillingSession(ABC):
|
|||
if status is not None:
|
||||
if status == CustomerPlan.ACTIVE:
|
||||
assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD
|
||||
do_change_plan_status(plan, status)
|
||||
with transaction.atomic(): # nocoverage
|
||||
# Switch to a different plan was cancelled. We end the next plan
|
||||
# and set the current one as active.
|
||||
if plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END:
|
||||
next_plan = self.get_next_plan(plan)
|
||||
assert next_plan is not None
|
||||
do_change_plan_status(next_plan, CustomerPlan.ENDED)
|
||||
do_change_plan_status(plan, status)
|
||||
elif status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE:
|
||||
assert not plan.is_free_trial()
|
||||
assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD
|
||||
|
|
|
@ -169,9 +169,12 @@ def remote_server_billing_page(
|
|||
context["sponsorship_pending"] = True
|
||||
|
||||
if (
|
||||
billing_session.remote_server.plan_type == RemoteZulipServer.PLAN_TYPE_SELF_HOSTED
|
||||
or customer is None
|
||||
customer is None
|
||||
or get_current_plan_by_customer(customer) is None
|
||||
or (
|
||||
billing_session.get_legacy_remote_server_new_plan_name(customer) is None
|
||||
and billing_session.remote_server.plan_type == RemoteZulipServer.PLAN_TYPE_SELF_HOSTED
|
||||
)
|
||||
):
|
||||
return HttpResponseRedirect(
|
||||
reverse(
|
||||
|
|
|
@ -252,7 +252,7 @@
|
|||
<input name="status" type="hidden" value="{{ CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL }}" />
|
||||
{% elif downgrade_at_end_of_free_trial %}
|
||||
<input name="status" type="hidden" value="{{ CustomerPlan.FREE_TRIAL }}" />
|
||||
{% elif downgrade_at_end_of_cycle %}
|
||||
{% elif downgrade_at_end_of_cycle or is_server_on_legacy_plan %}
|
||||
<input name="status" type="hidden" value="{{ CustomerPlan.ACTIVE }}" />
|
||||
{% else %}
|
||||
<input name="status" type="hidden" value="{{ CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE }}" />
|
||||
|
@ -392,4 +392,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="confirm-cancel-legacy-server-upgrade-modal" class="micromodal" aria-hidden="true">
|
||||
<div class="modal__overlay" tabindex="-1">
|
||||
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">
|
||||
<header class="modal__header">
|
||||
<h1 class="modal__title dialog_heading">
|
||||
Downgrade?
|
||||
</h1>
|
||||
<button class="modal__close" aria-label="{{ _('Close modal') }}" data-micromodal-close></button>
|
||||
</header>
|
||||
<main class="modal__content">
|
||||
<p>
|
||||
Lose benefits?
|
||||
</p>
|
||||
</main>
|
||||
<footer class="modal__footer">
|
||||
<button class="modal__btn dialog_exit_button" aria-label="{{ '(Close this dialog window)' }}" data-micromodal-close>{{ _('Never mind') }}</button>
|
||||
<button class="modal__btn dialog_submit_button">
|
||||
<span>{{ _('Downgrade') }}</span>
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -173,6 +173,26 @@ export function initialize(): void {
|
|||
portico_modals.open($modal.attr("id")!);
|
||||
});
|
||||
|
||||
$("#cancel-legacy-server-upgrade").on("click", (e) => {
|
||||
e.preventDefault();
|
||||
portico_modals.open("confirm-cancel-legacy-server-upgrade-modal");
|
||||
});
|
||||
|
||||
$("#confirm-cancel-legacy-server-upgrade-modal .dialog_submit_button").on("click", (e) => {
|
||||
helpers.create_ajax_request(
|
||||
`/json${billing_base_url}/billing/plan`,
|
||||
"planchange",
|
||||
[],
|
||||
"PATCH",
|
||||
() =>
|
||||
window.location.replace(
|
||||
`${billing_base_url}/upgrade/?success_message=` +
|
||||
encodeURIComponent("Your plan is no longer scheduled for an upgrade."),
|
||||
),
|
||||
);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#confirm-licenses-modal-increase, #confirm-licenses-modal-decrease").on(
|
||||
"click",
|
||||
".dialog_submit_button",
|
||||
|
|
Loading…
Reference in New Issue