forked from CGM_Public/pretix_original
Minor changes to the shopping cart
This commit is contained in:
@@ -32,13 +32,17 @@
|
|||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
.price, .count {
|
.price, .count {
|
||||||
text-align: center;
|
text-align: right;
|
||||||
}
|
}
|
||||||
.price small,
|
.price small,
|
||||||
.availability-box small {
|
.availability-box small {
|
||||||
display: block;
|
display: block;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.total {
|
||||||
|
border-top: 1px solid @table-border-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.checkout-button-row {
|
.checkout-button-row {
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
|
|||||||
@@ -1,59 +1,63 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% if cart %}
|
{% for line in cart.positions %}
|
||||||
<div class="panel panel-primary">
|
<div class="row-fluid cart-row">
|
||||||
<div class="panel-heading">
|
<div class="col-md-4 col-xs-6">
|
||||||
<h3 class="panel-title">{% trans "Your cart" %}</h3>
|
<strong>{{ line.item }}</strong>
|
||||||
|
{% if line.variation %}
|
||||||
|
– {{ line.variation }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="col-md-3 col-xs-6 price">
|
||||||
{% for line in cart %}
|
{{ event.currency }} {{ line.price|floatformat:2 }}
|
||||||
<div class="row-fluid cart-row">
|
|
||||||
<div class="col-md-4 col-xs-6">
|
|
||||||
<strong>{{ line.item }}</strong>
|
|
||||||
{% if line.variation %}
|
|
||||||
– {{ line.variation }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 col-xs-6 price">
|
|
||||||
{{ event.currency }} {{ line.price|floatformat:2 }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-xs-6 count">
|
|
||||||
<form action="{% url "presale:event.cart.remove" event=event.slug organizer=event.organizer.slug %}"
|
|
||||||
method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% if line.variation %}
|
|
||||||
<input type="hidden" name="variation_{{ line.item.identity }}_{{ line.variation.identity }}"
|
|
||||||
value="1" />
|
|
||||||
{% else %}
|
|
||||||
<input type="hidden" name="item_{{ line.item.identity }}"
|
|
||||||
value="1" />
|
|
||||||
{% endif %}
|
|
||||||
<button class="btn btn-mini btn-link"><i class="fa fa-minus"></i></button>
|
|
||||||
</form>
|
|
||||||
{{ line.count }}
|
|
||||||
<form action="{% url "presale:event.cart.add" event=event.slug organizer=event.organizer.slug %}"
|
|
||||||
method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% if line.variation %}
|
|
||||||
<input type="hidden" name="variation_{{ line.item.identity }}_{{ line.variation.identity }}"
|
|
||||||
value="1" />
|
|
||||||
{% else %}
|
|
||||||
<input type="hidden" name="item_{{ line.item.identity }}"
|
|
||||||
value="1" />
|
|
||||||
{% endif %}
|
|
||||||
<button class="btn btn-mini btn-link"><i class="fa fa-plus"></i></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 col-xs-6 price">
|
|
||||||
<strong>{{ event.currency }} {{ line.total|floatformat:2 }}</strong>
|
|
||||||
{% if line.item.tax_rate %}
|
|
||||||
<br /><small>{% blocktrans trimmed with rate=line.item.tax_rate %}
|
|
||||||
incl. {{ rate }}% taxes
|
|
||||||
{% endblocktrans %}</small>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-2 col-xs-6 count">
|
||||||
|
{% if editable %}
|
||||||
|
<form action="{% url "presale:event.cart.remove" event=event.slug organizer=event.organizer.slug %}"
|
||||||
|
method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if line.variation %}
|
||||||
|
<input type="hidden" name="variation_{{ line.item.identity }}_{{ line.variation.identity }}"
|
||||||
|
value="1" />
|
||||||
|
{% else %}
|
||||||
|
<input type="hidden" name="item_{{ line.item.identity }}"
|
||||||
|
value="1" />
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn btn-mini btn-link"><i class="fa fa-minus"></i></button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
{{ line.count }}
|
||||||
|
{% if editable %}
|
||||||
|
<form action="{% url "presale:event.cart.add" event=event.slug organizer=event.organizer.slug %}"
|
||||||
|
method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if line.variation %}
|
||||||
|
<input type="hidden" name="variation_{{ line.item.identity }}_{{ line.variation.identity }}"
|
||||||
|
value="1" />
|
||||||
|
{% else %}
|
||||||
|
<input type="hidden" name="item_{{ line.item.identity }}"
|
||||||
|
value="1" />
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn btn-mini btn-link"><i class="fa fa-plus"></i></button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-xs-6 price">
|
||||||
|
<strong>{{ event.currency }} {{ line.total|floatformat:2 }}</strong>
|
||||||
|
{% if line.item.tax_rate %}
|
||||||
|
<br /><small>{% blocktrans trimmed with rate=line.item.tax_rate %}
|
||||||
|
incl. {{ rate }}% taxes
|
||||||
|
{% endblocktrans %}</small>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
|
<div class="row-fluid cart-row total">
|
||||||
|
<div class="col-md-4 col-xs-6">
|
||||||
|
<strong>{% trans "Total" %}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
|
||||||
|
<strong>{{ event.currency }} {{ cart.total|floatformat:2 }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,16 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event %}
|
{% if cart.positions %}
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">{% trans "Your cart" %}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=True %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<form method="post"
|
<form method="post"
|
||||||
action="{% url "presale:event.cart.add" organizer=request.event.organizer.slug event=request.event.slug %}?next={{ request.path_info|urlencode }}">
|
action="{% url "presale:event.cart.add" organizer=request.event.organizer.slug event=request.event.slug %}?next={{ request.path_info|urlencode }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@@ -38,15 +38,18 @@ class CartDisplayMixin(CartMixin):
|
|||||||
def keyfunc(pos):
|
def keyfunc(pos):
|
||||||
return pos.item_id, pos.variation_id, pos.price
|
return pos.item_id, pos.variation_id, pos.price
|
||||||
|
|
||||||
cart = []
|
positions = []
|
||||||
for k, g in groupby(sorted(cartpos, key=keyfunc), key=keyfunc):
|
for k, g in groupby(sorted(cartpos, key=keyfunc), key=keyfunc):
|
||||||
g = list(g)
|
g = list(g)
|
||||||
group = g[0]
|
group = g[0]
|
||||||
group.count = len(g)
|
group.count = len(g)
|
||||||
group.total = group.count * group.price
|
group.total = group.count * group.price
|
||||||
cart.append(group)
|
positions.append(group)
|
||||||
|
|
||||||
return cart
|
return {
|
||||||
|
'positions': positions,
|
||||||
|
'total': sum(p.total for p in positions),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class EventViewMixin:
|
class EventViewMixin:
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class CartActionMixin(CartMixin):
|
|||||||
def get_next_url(self):
|
def get_next_url(self):
|
||||||
if "next" in self.request.GET and '://' not in self.request.GET:
|
if "next" in self.request.GET and '://' not in self.request.GET:
|
||||||
return self.request.GET.get('next')
|
return self.request.GET.get('next')
|
||||||
|
elif "HTTP_REFERER" in self.request.META:
|
||||||
|
return self.request.META.get('HTTP_REFERER')
|
||||||
else:
|
else:
|
||||||
return reverse('presale:event.index', kwargs={
|
return reverse('presale:event.index', kwargs={
|
||||||
'event': self.request.event.slug,
|
'event': self.request.event.slug,
|
||||||
|
|||||||
Reference in New Issue
Block a user