Added setting to disable order cancelling for users

This commit is contained in:
Raphael Michel
2016-08-15 16:42:39 +02:00
parent 3dfdfdf5d0
commit 1cb956d508
7 changed files with 33 additions and 7 deletions

View File

@@ -178,7 +178,7 @@
{% endif %}
<div class="clearfix"></div>
</div>
{% if order.status == "n" %}
{% if order.status == "n" and order.can_user_cancel %}
<div class="row">
<div class="col-md-12 text-right">
<p>

View File

@@ -295,7 +295,7 @@ class OrderCancel(EventViewMixin, OrderDetailMixin, TemplateView):
self.kwargs = kwargs
if not self.order:
raise Http404(_('Unknown order code or not authorized to access this order.'))
if self.order.status not in (Order.STATUS_PENDING, Order.STATUS_EXPIRED):
if self.order.status not in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) or not self.order.can_user_cancel:
messages.error(request, _('You cannot cancel this order.'))
return redirect(self.get_order_url())
return super().dispatch(request, *args, **kwargs)
@@ -321,6 +321,9 @@ class OrderCancelDo(EventViewMixin, OrderDetailMixin, AsyncAction, View):
def post(self, request, *args, **kwargs):
if not self.order:
raise Http404(_('Unknown order code or not authorized to access this order.'))
if not self.order.can_user_cancel:
messages.error(request, _('You cannot cancel this order.'))
return redirect(self.get_order_url())
return self.do(self.order.pk)
def get_context_data(self, **kwargs):