Fix ZeroDivisionError if a voucher tag is given to a voucher with max_usages=0

Fix PRETIXEU-V7
This commit is contained in:
Raphael Michel
2019-02-08 13:59:05 +01:00
parent 17392f3ef4
commit cbf5c2ec1d

View File

@@ -105,7 +105,10 @@ class VoucherTags(EventPermissionRequiredMixin, TemplateView):
redeemed=Sum('redeemed')
)
for t in tags:
t['percentage'] = int((t['redeemed'] / t['total']) * 100)
if t['total'] == 0:
t['percentage'] = 0
else:
t['percentage'] = int((t['redeemed'] / t['total']) * 100)
ctx['tags'] = tags
return ctx