Fix voucher redemption and event index after c4bf73c

This commit is contained in:
Raphael Michel
2017-02-15 19:17:42 +01:00
parent c4bf73c8d6
commit 8b2257161f
3 changed files with 8 additions and 11 deletions

View File

@@ -36,7 +36,8 @@
</a>
{% endif %}
<strong>{{ item.name }}</strong>
{% if item.description %}<p>{{ item.description|localize|rich_text }}</p>{% endif %}
{% if item.description %}
<p>{{ item.description|localize|rich_text }}</p>{% endif %}
</div>
<div class="col-md-2 col-xs-6 price">
{% if item.min_price != item.max_price or item.free_price %}
@@ -65,10 +66,11 @@
placeholder="0"
min="{{ var.price|stringformat:"0.2f" }}"
name="price_{{ item.id }}_{{ var.id }}"
step="any" value="{{ var.price|stringformat:"0.2f" }}">
step="any"
value="{{ var.display_price|stringformat:"0.2f" }}">
</div>
{% else %}
{{ event.currency }} {{ var.price|floatformat:2 }}
{{ event.currency }} {{ var.display_price|floatformat:2 }}
{% endif %}
{% if item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
@@ -81,7 +83,7 @@
<label>
{% if max_times > 1 %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
max="{{ item.order_max }}" name="variation_{{ item.id }}_{{ var.id }}">
max="{{ item.order_max }}" name="variation_{{ item.id }}_{{ var.id }}">
{% else %}
<input type="radio" name="_voucher_item"
{% if options == 1 %}checked="checked"{% endif %}
@@ -135,7 +137,7 @@
<label>
{% if max_times > 1 %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
max="{{ item.order_max }}" name="item_{{ item.id }}">
max="{{ item.order_max }}" name="item_{{ item.id }}">
{% else %}
<input type="radio" name="_voucher_item"
{% if options == 1 %}checked="checked"{% endif %}

View File

@@ -195,9 +195,7 @@ class RedeemView(EventViewMixin, TemplateView):
var.cached_availability = (Quota.AVAILABILITY_OK, 1)
else:
var.cached_availability = list(var.check_quotas())
var.price = self.voucher.calculate_price(
var.default_price if var.default_price is not None else item.default_price
)
var.display_price = self.voucher.calculate_price(var.price)
if len(item.available_variations) > 0:
item.min_price = min([v.price for v in item.available_variations])

View File

@@ -14,7 +14,6 @@ from django.views.generic import TemplateView
from pretix.base.models import ItemVariation
from pretix.multidomain.urlreverse import eventreverse
from . import CartMixin, EventViewMixin
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
@@ -71,7 +70,6 @@ def get_grouped_items(event):
if var.cached_availability[1] is not None else sys.maxsize,
int(event.settings.max_items_per_order))
display_add_to_cart = display_add_to_cart or var.order_max > 0
var.price = var.default_price if var.default_price is not None else item.default_price
if len(item.available_variations) > 0:
item.min_price = min([v.price for v in item.available_variations])
item.max_price = max([v.price for v in item.available_variations])
@@ -105,7 +103,6 @@ class EventIndex(EventViewMixin, CartMixin, TemplateView):
class EventAuth(View):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)