mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
committed by
Raphael Michel
parent
b64fef4b08
commit
8118423153
@@ -15,19 +15,32 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=True %}
|
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=True %}
|
||||||
<div class="cart-row row">
|
<em id="cart-deadline" data-expires="{{ cart.first_expiry|date:"Y-m-d H:i:sO" }}">
|
||||||
<div class="col-md-6 col-xs-12">
|
{% if cart.minutes_left > 0 %}
|
||||||
<em id="cart-deadline" data-expires="{{ cart.first_expiry|date:"Y-m-d H:i:sO" }}">
|
{% blocktrans trimmed with minutes=cart.minutes_left %}
|
||||||
{% if cart.minutes_left > 0 %}
|
The items in your cart are reserved for you for {{ minutes }} minutes.
|
||||||
{% blocktrans trimmed with minutes=cart.minutes_left %}
|
{% endblocktrans %}
|
||||||
The items in your cart are reserved for you for {{ minutes }} minutes.
|
{% else %}
|
||||||
{% endblocktrans %}
|
{% trans "The items in your cart are no longer reserved for you." %}
|
||||||
{% else %}
|
{% endif %}
|
||||||
{% trans "The items in your cart are no longer reserved for you." %}
|
</em>
|
||||||
{% endif %}
|
<div class="row checkout-button-row">
|
||||||
</em>
|
<div class="col-md-4 col-xs-12">
|
||||||
|
<form method="post" data-asynctask action="{% eventurl request.event "presale:event.cart.remove.all" %}" >
|
||||||
|
{% csrf_token %}
|
||||||
|
{% for line in cart.positions %}
|
||||||
|
{% if line.variation %}
|
||||||
|
<input type="hidden" name="variation_{{ line.item.id }}_{{ line.variation.id }}" value="{{ line.count }}" />
|
||||||
|
<input type="hidden" name="price_{{ line.item.id }}_{{ line.variation.id }}" value="{{ line.price }}" />
|
||||||
|
{% else %}
|
||||||
|
<input type="hidden" name="item_{{ line.item.id }}" value="{{ line.count }}" />
|
||||||
|
<input type="hidden" name="price_{{ line.item.id }}" value="{{ line.price }}" />
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<button class="btn btn-block btn-default btn-lg" type="submit"><i class="fa fa-close"></i> {% trans "Empty cart" %}</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 col-md-offset-2 col-xs-12">
|
<div class="col-md-4 col-md-offset-4 col-xs-12">
|
||||||
<a class="btn btn-block btn-primary btn-lg"
|
<a class="btn btn-block btn-primary btn-lg"
|
||||||
href="{% eventurl request.event "presale:event.checkout.start" %}">
|
href="{% eventurl request.event "presale:event.checkout.start" %}">
|
||||||
<i class="fa fa-shopping-cart"></i> {% trans "Proceed with checkout" %}
|
<i class="fa fa-shopping-cart"></i> {% trans "Proceed with checkout" %}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import pretix.presale.views.user
|
|||||||
event_patterns = [
|
event_patterns = [
|
||||||
url(r'^cart/add$', pretix.presale.views.cart.CartAdd.as_view(), name='event.cart.add'),
|
url(r'^cart/add$', pretix.presale.views.cart.CartAdd.as_view(), name='event.cart.add'),
|
||||||
url(r'^cart/remove$', pretix.presale.views.cart.CartRemove.as_view(), name='event.cart.remove'),
|
url(r'^cart/remove$', pretix.presale.views.cart.CartRemove.as_view(), name='event.cart.remove'),
|
||||||
|
url(r'^cart/removeall$', pretix.presale.views.cart.CartRemoveAll.as_view(), name='event.cart.remove.all'),
|
||||||
url(r'^checkout/start$', pretix.presale.views.checkout.CheckoutView.as_view(), name='event.checkout.start'),
|
url(r'^checkout/start$', pretix.presale.views.checkout.CheckoutView.as_view(), name='event.checkout.start'),
|
||||||
url(r'^redeem$', pretix.presale.views.cart.RedeemView.as_view(),
|
url(r'^redeem$', pretix.presale.views.cart.RedeemView.as_view(),
|
||||||
name='event.redeem'),
|
name='event.redeem'),
|
||||||
|
|||||||
@@ -126,6 +126,32 @@ class CartRemove(EventViewMixin, CartActionMixin, AsyncAction, View):
|
|||||||
return redirect(self.get_error_url())
|
return redirect(self.get_error_url())
|
||||||
|
|
||||||
|
|
||||||
|
class CartRemoveAll(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||||
|
task = remove_items_from_cart
|
||||||
|
|
||||||
|
def get_success_message(self, value):
|
||||||
|
return _('Your cart is empty.')
|
||||||
|
|
||||||
|
def get_error_message(self, exception):
|
||||||
|
if isinstance(exception, dict) and exception['exc_type'] == 'CartError':
|
||||||
|
return exception['exc_message']
|
||||||
|
elif isinstance(exception, CartError):
|
||||||
|
return str(exception)
|
||||||
|
return super().get_error_message(exception)
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
items = self._items_from_post_data()
|
||||||
|
if items:
|
||||||
|
return self.do(self.request.event.id, items, self.request.session.session_key)
|
||||||
|
else:
|
||||||
|
if 'ajax' in self.request.GET or 'ajax' in self.request.POST:
|
||||||
|
return JsonResponse({
|
||||||
|
'redirect': self.get_error_url()
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return redirect(self.get_error_url())
|
||||||
|
|
||||||
|
|
||||||
class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
|
class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||||
task = add_items_to_cart
|
task = add_items_to_cart
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user