Allow for vouchers that are valid for multiple items

This commit is contained in:
Raphael Michel
2016-05-04 17:50:19 +02:00
parent bda0075613
commit 09cee356b0
18 changed files with 669 additions and 154 deletions

View File

@@ -189,27 +189,6 @@
</section>
{% endfor %}
{% if event.presale_is_running %}
{% if vouchers_exist %}
<div class="row-fluid voucher-row">
<div class="col-md-4 col-md-offset-8 col-xs-12">
<div id="voucher-box">
<label for="voucher">{% trans "Redeem a voucher" %}</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-ticket fa-fw"></i></span>
<input type="text" class="form-control" name="voucher" id="voucher"
placeholder="{% trans "Voucher code" %}">
</div>
</div>
<div id="voucher-toggle">
<a href="javascript:void(0);">
<span class="fa fa-ticket"></span> {% trans "Redeem a voucher" %}
</a>
</div>
</div>
<div class="clearfix"></div>
</div>
{% endif %}
<div class="row-fluid checkout-button-row">
<div class="col-md-4 col-md-offset-8 col-xs-12">
<button class="btn btn-block btn-primary btn-lg" type="submit">
@@ -221,4 +200,24 @@
{% endif %}
</form>
{% endif %}
{% if vouchers_exist %}
<h2>{% trans "Redeem a voucher" %}</h2>
<form method="get" action="{% eventurl event "presale:event.redeem" %}">
<div class="row-fluid">
<div class="col-md-8 col-sm-6 col-xs-12">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-ticket fa-fw"></i></span>
<input type="text" class="form-control" name="voucher" id="voucher"
placeholder="{% trans "Voucher code" %}">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<button class="btn btn-block btn-primary" type="submit">
{% trans "Redeem voucher" %}
</button>
</div>
<div class="clearfix"></div>
</div>
</form>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,154 @@
{% extends "pretixpresale/event/base.html" %}
{% load i18n %}
{% load eventurl %}
{% load thumbnail %}
{% block title %}{% trans "Voucher redemption" %}{% endblock %}
{% block content %}
<h2>{% trans "Voucher redemption" %}</h2>
<p>
{% blocktrans trimmed %}
You entered a voucher code that allows you to buy one of the following products at the specified price:
{% endblocktrans %}
</p>
{% if event.presale_is_running or event.settings.show_items_outside_presale_period %}
<form method="post" data-asynctask
action="{% eventurl request.event "presale:event.cart.add" %}?next={{ request.path|urlencode }}">
{% csrf_token %}
<input type="hidden" name="_voucher_code" value="{{ voucher.code }}">
{% for tup in items_by_category %}
<section>
{% if tup.0 %}<h3>{{ tup.0.name }}</h3>{% endif %}
{% for item in tup.1 %}
{% if item.has_variations %}
<div class="item-with-variations">
<div class="row-fluid product-row headline">
<div class="col-md-8 col-xs-12">
{% if item.picture %}
<a href="{{ item.picture.url }}" class="productpicture"
data-title="{{ item.name }}"
data-lightbox="{{ item.id }}">
<img src="{{ item.picture|thumbnail_url:'productlist' }}"
alt="{{ item.name }}"/>
</a>
{% endif %}
<strong>{{ item.name }}</strong>
{% if item.description %}<p>{{ item.description }}</p>{% endif %}
</div>
<div class="col-md-2 col-xs-6 price">
{% if item.min_price != item.max_price or item.free_price %}
{% blocktrans trimmed with minprice=item.min_price|floatformat:2 currency=event.currency %}
from {{ currency }} {{ minprice }}
{% endblocktrans %}
{% else %}
{{ event.currency }} {{ item.min_price|floatformat:2 }}
{% endif %}
</div>
<div class="col-md-2 col-xs-6 availability-box">
</div>
<div class="clearfix"></div>
</div>
<div class="">
{% for var in item.available_variations %}
<div class="row-fluid product-row variation">
<div class="col-md-8 col-xs-12">
{{ var }}
</div>
<div class="col-md-2 col-xs-6 price">
{% if item.free_price %}
<div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price"
placeholder="0"
min="{{ var.price|stringformat:"0.2f" }}"
name="price_{{ item.id }}_{{ var.id }}"
step="0.01" value="{{ var.price|stringformat:"0.2f" }}">
</div>
{% else %}
{{ event.currency }} {{ var.price|floatformat:2 }}
{% endif %}
{% if item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
</div>
{% if var.cached_availability.0 == 100 %}
<div class="col-md-2 col-xs-6 availability-box available radio-box">
<label>
<input type="radio" name="_voucher_item"
{% if options == 1 %}checked="checked"{% endif %}
value="variation_{{ item.id }}_{{ var.id }}">
</label>
</div>
{% else %}
{% include "pretixpresale/event/fragment_availability.html" with avail=var.cached_availability.0 %}
{% endif %}
<div class="clearfix"></div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div class="row-fluid product-row simple">
<div class="col-md-8 col-xs-12">
{% if item.picture %}
<a href="{{ item.picture.url }}" class="productpicture"
data-title="{{ item.name }}"
data-lightbox="{{ item.id }}">
<img src="{{ item.picture|thumbnail_url:'productlist' }}"
alt="{{ item.name }}"/>
</a>
{% endif %}
<strong>{{ item.name }}</strong>
{% if item.description %}
<p class="description">{{ item.description }}</p>{% endif %}
</div>
<div class="col-md-2 col-xs-6 price">
{% if item.free_price %}
<div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" placeholder="0"
min="{{ item.price|stringformat:"0.2f" }}"
name="price_{{ item.id }}"
step="0.01" value="{{ item.price|stringformat:"0.2f" }}">
</div>
{% else %}
{{ event.currency }} {{ item.price|floatformat:2 }}
{% endif %}
{% if item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
</div>
{% if item.cached_availability.0 == 100 %}
<div class="col-md-2 col-xs-6 availability-box available radio-box">
<label>
<input type="radio" name="_voucher_item"
{% if options == 1 %}checked="checked"{% endif %}
value="item_{{ item.id }}">
</label>
</div>
{% else %}
{% include "pretixpresale/event/fragment_availability.html" with avail=item.cached_availability.0 %}
{% endif %}
<div class="clearfix"></div>
</div>
{% endif %}
{% endfor %}
</section>
{% endfor %}
{% if event.presale_is_running %}
<div class="row-fluid checkout-button-row">
<div class="col-md-4 col-md-offset-8 col-xs-12">
<button class="btn btn-block btn-primary btn-lg" type="submit">
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
</button>
</div>
<div class="clearfix"></div>
</div>
{% endif %}
</form>
{% endif %}
{% endblock %}