Added voucher redemption

This commit is contained in:
Raphael Michel
2016-02-11 16:41:22 +01:00
parent bcde964ea3
commit f18a180ae4
15 changed files with 226 additions and 66 deletions

View File

@@ -85,6 +85,12 @@
{% if line.variation %}
{{ line.variation }}
{% endif %}
{% if line.voucher %}
<br /><span class="fa fa-ticket"></span> {% trans "Voucher code used:" %}
<a href="{% url "control:event.voucher" event=request.event.slug organizer=request.event.organizer.slug voucher=line.voucher.pk %}">
{{ line.voucher.code }}
</a>
{% endif %}
{% if line.has_questions %}
<dl>
{% if line.item.admission and event.settings.attendee_names_asked %}

View File

@@ -4,6 +4,11 @@
{% block title %}{% trans "Voucher" %}{% endblock %}
{% block inside %}
<h1>{% trans "Voucher" %}</h1>
{% if voucher.redeemed %}
<div class="alert alert-warning">
{% trans "This voucher already has been used. It is not recommended to modify it." %}
</div>
{% endif %}
<form action="" method="post" class="form-horizontal">
{% csrf_token %}
{% bootstrap_form_errors form %}

View File

@@ -25,7 +25,7 @@
<strong><a href="
{% url "control:event.voucher" organizer=request.event.organizer.slug event=request.event.slug voucher=v.id %}">{{ v.code }}</a></strong>
</td>
<td>{% if v.is_ordered %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
<td>{% if v.redeemed %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
<td>{{ v.valid_until|date }}</td>
<td>{{ v.item }}</td>
<td class="text-right">

View File

@@ -135,8 +135,8 @@ class OrderDetail(OrderView):
def keyfunc(pos):
if (pos.item.admission and self.request.event.settings.attendee_names_asked) \
or pos.item.questions.all():
return pos.id, 0, 0, 0
return 0, pos.item_id, pos.variation_id, pos.price
return pos.id, 0, 0, 0, None
return 0, pos.item_id, pos.variation_id, pos.price, pos.voucher
positions = []
for k, g in groupby(sorted(list(cartpos), key=keyfunc), key=keyfunc):