Allow to add a prefix when generating voucher codes (#518)

This commit is contained in:
Tobias Kunze
2017-06-16 23:21:23 +02:00
committed by Raphael Michel
parent 8e3cc0df0c
commit 8fa490c938
4 changed files with 11 additions and 5 deletions

View File

@@ -13,8 +13,10 @@ from .event import Event
from .items import Item, ItemVariation, Quota
def _generate_random_code():
def _generate_random_code(prefix=None):
charset = list('ABCDEFGHKLMNPQRSTUVWXYZ23456789')
if prefix:
return prefix + get_random_string(length=settings.ENTROPY['voucher_code'], allowed_chars=charset)
return get_random_string(length=settings.ENTROPY['voucher_code'], allowed_chars=charset)