Added option to bulk create vouchers via the WebUI.

Closes #9
This commit is contained in:
Johannes Erwerle 2026-10-18 15:04:00 +02:00
parent f3d152b454
commit baea657d1a
5 changed files with 79 additions and 11 deletions

View file

@ -11,14 +11,7 @@ class Command(BaseCommand):
parser.add_argument("amount", type=int)
def handle(self, *args, **options):
unabmigous_characters = "abcdefghijkmnopqrstuvwxyzACDEFHJKLMNPQRTUVWXY1234679"
vouchers = set()
while len(vouchers) < options["amount"]:
random_part = "".join(choices(unabmigous_characters, k=5))
vouchers.add(f"{options['prefix']}-{random_part}")
Voucher.objects.bulk_create(Voucher(code=v) for v in vouchers)
vouchers = Voucher.bulk_generate(options["prefix"], options["amount"])
header = r"""\begin{document}
\begin{center}