Introduce cancellation requests (#1627)

* Allow to adjust the cancellation fee without JS

* Introduce cancellation requests

* ignore→delete

* Change a few things after Martin's review

* Add a few tests
This commit is contained in:
Raphael Michel
2020-03-25 14:13:55 +01:00
committed by GitHub
parent 173a23722a
commit 8a6334bd86
24 changed files with 352 additions and 33 deletions

View File

@@ -94,6 +94,14 @@
{% endif %}
{% eventsignal event "pretix.presale.signals.order_info_top" order=order request=request %}
{% if order.status == "p" or order.status == "c" %}
{% if order.cancellation_requests.exists %}
<div class="alert alert-info">
{% blocktrans trimmed %}
We've received your request to cancel this order. Please stay patient while the event organizer
decides on the cancellation.
{% endblocktrans %}
</div>
{% endif %}
{% if refunds %}
<div class="alert alert-info">
{% for r in refunds %}
@@ -280,17 +288,31 @@
{% if order.status == "p" and order.total != 0 %}
{% if order.user_cancel_fee >= order.total %}
<p>
{% blocktrans trimmed %}
You can cancel this order, but you will not receive a refund.
{% endblocktrans %}
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
{% blocktrans trimmed %}
You can request to cancel this order, but you will not receive a refund.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
You can cancel this order, but you will not receive a refund.
{% endblocktrans %}
{% endif %}
{% trans "This will invalidate all tickets in this order." %}
</p>
{% elif order.user_cancel_fee %}
<p>
{% blocktrans trimmed with fee=order.user_cancel_fee|money:request.event.currency %}
You can cancel this order. In this case, a cancellation fee of <strong>{{ fee }}</strong>
will be kept and you will receive a refund of the remainder.
{% endblocktrans %}
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
{% blocktrans trimmed with fee=order.user_cancel_fee|money:request.event.currency %}
You can request to cancel this order. If your request is approved, a cancellation
fee of <strong>{{ fee }}</strong> will be kept and you will receive a refund of
the remainder.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with fee=order.user_cancel_fee|money:request.event.currency %}
You can cancel this order. In this case, a cancellation fee of <strong>{{ fee }}</strong>
will be kept and you will receive a refund of the remainder.
{% endblocktrans %}
{% endif %}
{% if request.event.settings.cancel_allow_user_paid_refund_as_giftcard == "force" %}
{% trans "The refund will be issued in form of a gift card that you can use for further purchases." %}
{% elif request.event.settings.cancel_allow_user_paid_refund_as_giftcard == "option" %}
@@ -302,9 +324,16 @@
</p>
{% else %}
<p>
{% blocktrans trimmed %}
You can cancel this order and receive a full refund.
{% endblocktrans %}
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
{% blocktrans trimmed %}
You can request to cancel this order. If your request is approved, you get a full
refund.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
You can cancel this order and receive a full refund.
{% endblocktrans %}
{% endif %}
{% if request.event.settings.cancel_allow_user_paid_refund_as_giftcard == "force" %}
{% trans "The refund will be issued in form of a gift card that you can use for further purchases." %}
{% elif request.event.settings.cancel_allow_user_paid_refund_as_giftcard == "option" %}

View File

@@ -6,20 +6,35 @@
{% block title %}{% trans "Cancel order" %}{% endblock %}
{% block content %}
<h2>
{% blocktrans trimmed with code=order.code %}
Cancel order: {{ code }}
{% endblocktrans %}
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
{% blocktrans trimmed with code=order.code %}
Request cancellation: {{ code }}
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with code=order.code %}
Cancel order: {{ code }}
{% endblocktrans %}
{% endif %}
</h2>
<form method="post"
action="{% eventurl request.event "presale:event.order.cancel.do" secret=order.secret order=order.code %}"
data-asynctask
class="">
<p>
{% blocktrans trimmed %}
If you cancel this order, all tickets will be invalidated and you can no longer use them. You cannot
revert this action.
{% endblocktrans %}
</p>
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
<p>
{% blocktrans trimmed %}
You can request the cancellation of your order on this page. The event organizer will then decide
on your request. If they approve, your order will be canceled and all tickets will be invalidated.
{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans trimmed %}
If you cancel this order, all tickets will be invalidated and you can no longer use them. You cannot
revert this action.
{% endblocktrans %}
</p>
{% endif %}
{% if request.event.settings.cancel_allow_user_paid_adjust_fees %}
<p>
@@ -36,19 +51,18 @@
{% trans "However, if you want us to help keep the lights on here, please consider using the slider below to request a smaller refund. Thank you!" %}
</p>
<div class="cancel-fee-slider">
<div id="cancel-fee-keep"></div>
<div id="cancel-fee-keep">Enter how much we can keep:</div>
<input
id="cancel-fee-slider"
type="text"
name="cancel_fee"
class="col-md-6 col-sm-12"
value="{{ cancel_fee|stringformat:".2f" }}"
data-slider-min="{{ cancel_fee|stringformat:".2f" }}"
data-slider-value="{{ cancel_fee|stringformat:".2f" }}"
data-slider-step="0.01"
data-slider-max="{{ order.payment_refund_sum|stringformat:".2f" }}"
data-slider-tooltip="hide"/>
<div id="cancel-fee-refund">AS</div>
<div id="cancel-fee-refund"></div>
</div>
<div class="text-center" id="cancel-fee-custom-link">
<a id="cancel-fee-custom"><small>Enter custom amount</small></a>
@@ -128,7 +142,11 @@
</div>
<div class="col-md-4 col-md-offset-4">
<button class="btn btn-block btn-danger btn-lg" type="submit">
{% trans "Yes, cancel order" %}
{% if request.event.settings.cancel_allow_user_paid_require_approval %}
{% trans "Yes, request cancellation" %}
{% else %}
{% trans "Yes, cancel order" %}
{% endif %}
</button>
</div>
<div class="clearfix"></div>

View File

@@ -765,7 +765,15 @@ class OrderCancelDo(EventViewMixin, OrderDetailMixin, AsyncAction, View):
self.request.POST.get('giftcard') == 'true'
)
)
return self.do(self.order.pk, cancellation_fee=fee, try_auto_refund=True, refund_as_giftcard=giftcard)
if self.request.event.settings.cancel_allow_user_paid_require_approval:
self.order.cancellation_requests.create(
cancellation_fee=fee,
refund_as_giftcard=giftcard,
)
self.order.log_action('pretix.event.order.refund.requested')
return self.success(None)
else:
return self.do(self.order.pk, cancellation_fee=fee, try_auto_refund=True, refund_as_giftcard=giftcard)
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
@@ -773,7 +781,10 @@ class OrderCancelDo(EventViewMixin, OrderDetailMixin, AsyncAction, View):
return ctx
def get_success_message(self, value):
return _('The order has been canceled.')
if self.request.event.settings.cancel_allow_user_paid_require_approval:
return _('The cancellation has been requested.')
else:
return _('The order has been canceled.')
@method_decorator(xframe_options_exempt, 'dispatch')