diff --git a/src/pretix/control/templates/pretixcontrol/vouchers/base.html b/src/pretix/control/templates/pretixcontrol/vouchers/base.html
index a795273f3..a00f8ed4f 100644
--- a/src/pretix/control/templates/pretixcontrol/vouchers/base.html
+++ b/src/pretix/control/templates/pretixcontrol/vouchers/base.html
@@ -10,6 +10,11 @@
{% trans "All Vouchers" %}
+
+
+ {% trans "Tags" %}
+
+
{% block inside %}
{% endblock %}
diff --git a/src/pretix/control/templates/pretixcontrol/vouchers/tags.html b/src/pretix/control/templates/pretixcontrol/vouchers/tags.html
new file mode 100644
index 000000000..198769ae2
--- /dev/null
+++ b/src/pretix/control/templates/pretixcontrol/vouchers/tags.html
@@ -0,0 +1,47 @@
+{% extends "pretixcontrol/vouchers/base.html" %}
+{% load i18n %}
+{% block inside %}
+
+ {% blocktrans trimmed %}
+ If you add a "tag" to a voucher, you can here see statistics on their usage.
+ {% endblocktrans %}
+
+ {% if tags|length == 0 %}
+
+
+ {% blocktrans trimmed %}
+ You haven't added any tags to vouchers yet.
+ {% endblocktrans %}
+
+
+ {% else %}
+
+
+
+
+ | {% trans "Tag" %} |
+ {% trans "Redeemed vouchers" %} |
+
+
+
+ {% for t in tags %}
+
+ |
+
+ {{ t.tag }}
+ ({{ t.redeemed }} / {{ t.total }})
+ |
+
+
+ |
+
+ {% endfor %}
+
+
+
+ {% endif %}
+{% endblock %}
diff --git a/src/pretix/control/urls.py b/src/pretix/control/urls.py
index b6001ea1a..8715274b3 100644
--- a/src/pretix/control/urls.py
+++ b/src/pretix/control/urls.py
@@ -59,6 +59,7 @@ urlpatterns = [
name='event.items.quotas.delete'),
url(r'^quotas/add$', item.QuotaCreate.as_view(), name='event.items.quotas.add'),
url(r'^vouchers/$', vouchers.VoucherList.as_view(), name='event.vouchers'),
+ url(r'^vouchers/tags/$', vouchers.VoucherTags.as_view(), name='event.vouchers.tags'),
url(r'^vouchers/(?P\d+)/$', vouchers.VoucherUpdate.as_view(), name='event.voucher'),
url(r'^vouchers/(?P\d+)/delete$', vouchers.VoucherDelete.as_view(),
name='event.voucher.delete'),
diff --git a/src/pretix/control/views/vouchers.py b/src/pretix/control/views/vouchers.py
index c0f80c96a..62e0a1c57 100644
--- a/src/pretix/control/views/vouchers.py
+++ b/src/pretix/control/views/vouchers.py
@@ -1,11 +1,13 @@
from django.contrib import messages
from django.core.urlresolvers import resolve, reverse
from django.db import transaction
-from django.db.models import Q
+from django.db.models import Count, Q, Sum
from django.http import Http404, HttpResponseRedirect
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
-from django.views.generic import CreateView, DeleteView, ListView, UpdateView
+from django.views.generic import (
+ CreateView, DeleteView, ListView, TemplateView, UpdateView,
+)
from pretix.base.models import Voucher
from pretix.control.forms.vouchers import VoucherBulkForm, VoucherForm
@@ -39,6 +41,24 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
return qs
+class VoucherTags(EventPermissionRequiredMixin, TemplateView):
+ template_name = 'pretixcontrol/vouchers/tags.html'
+ permission = 'can_change_vouchers'
+
+ def get_context_data(self, **kwargs):
+ ctx = super().get_context_data(**kwargs)
+
+ tags = self.request.event.vouchers.order_by().filter(tag__isnull=False).values('tag').annotate(
+ total=Count('id'),
+ redeemed=Sum('redeemed')
+ )
+ for t in tags:
+ t['percentage'] = int((t['redeemed'] / t['total']) * 100)
+
+ ctx['tags'] = tags
+ return ctx
+
+
class VoucherDelete(EventPermissionRequiredMixin, DeleteView):
model = Voucher
template_name = 'pretixcontrol/vouchers/delete.html'
diff --git a/src/static/pretixcontrol/scss/main.scss b/src/static/pretixcontrol/scss/main.scss
index f5afd374b..5b4fefb55 100644
--- a/src/static/pretixcontrol/scss/main.scss
+++ b/src/static/pretixcontrol/scss/main.scss
@@ -111,4 +111,12 @@ h1 .btn-sm {
font-size: 200px;
color: #ccc;
}
-}
\ No newline at end of file
+}
+.table .progress {
+ margin-bottom: 0;
+}
+
+@for $i from 0 through 100 {
+ .progress-bar-#{$i} { width: 1% * $i; }
+}
+