mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
* prevent some words from occurring in order codes * Use regex to match against blacklist * Prevent some words from occurring in voucher codes * Rename blacklist to banlist
This commit is contained in:
@@ -10,6 +10,7 @@ from django.utils.timezone import now
|
||||
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from django_scopes import ScopedManager, scopes_disabled
|
||||
|
||||
from pretix.base.banlist import banned
|
||||
from pretix.base.models import SeatCategoryMapping
|
||||
|
||||
from ..decimal import round_decimal
|
||||
@@ -21,9 +22,12 @@ from .orders import Order
|
||||
|
||||
def _generate_random_code(prefix=None):
|
||||
charset = list('ABCDEFGHKLMNPQRSTUVWXYZ23456789')
|
||||
rnd = None
|
||||
while not rnd or banned(rnd):
|
||||
rnd = get_random_string(length=settings.ENTROPY['voucher_code'], allowed_chars=charset)
|
||||
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)
|
||||
return prefix + rnd
|
||||
return rnd
|
||||
|
||||
|
||||
@scopes_disabled()
|
||||
|
||||
Reference in New Issue
Block a user