From 71e72fb98bcf4dcf7a149b86715a160ab4ef86f5 Mon Sep 17 00:00:00 2001 From: Johannes Erwerle Date: Fri, 5 Jun 2026 11:11:55 +0200 Subject: [PATCH 1/2] Added command to bulk-create vouchers --- .../webui/management/commands/add_vouchers.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 community_backup/webui/management/commands/add_vouchers.py diff --git a/community_backup/webui/management/commands/add_vouchers.py b/community_backup/webui/management/commands/add_vouchers.py new file mode 100644 index 0000000..f983d92 --- /dev/null +++ b/community_backup/webui/management/commands/add_vouchers.py @@ -0,0 +1,39 @@ +from django.core.management.base import BaseCommand +from random import choices +from ...models import Voucher + + +class Command(BaseCommand): + help = "bulk-add vouchers with a given prefix and generate a latex output to render them" + + def add_arguments(self, parser): + parser.add_argument("prefix", type=str) + 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) + + header = r"""\begin{document} +\begin{center} +""" + output = header + even = False + for v in vouchers: + output += f"\\voucher{{{v}}}" + if even: + output += "\\newline\n" + else: + output += "\n" + even = not even + + output += r"""\end{center} +\end{document}""" + + print(output) From a0b69596c873e0cfa4c0d4c1e82b8ed677565805 Mon Sep 17 00:00:00 2001 From: Johannes Erwerle Date: Fri, 5 Jun 2026 11:13:11 +0200 Subject: [PATCH 2/2] bumped version to 0.12 --- community_backup/community_backup/settings.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/community_backup/community_backup/settings.py b/community_backup/community_backup/settings.py index e46f420..f784284 100644 --- a/community_backup/community_backup/settings.py +++ b/community_backup/community_backup/settings.py @@ -117,7 +117,7 @@ TASKS = {"default": {"BACKEND": "django.tasks.backends.immediate.ImmediateBacken STATIC_ROOT = BASE_DIR.parent.parent / "static" -RELEASE_VERSION = "0.11" +RELEASE_VERSION = "0.12" # Import settings from configuration.py try: diff --git a/pyproject.toml b/pyproject.toml index b3c7394..2412b09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "community_backup" -version = "0.11" +version = "0.12" description = "Add your description here" readme = "README.md" requires-python = ">=3.13"