Skip to content

feat: add voucher bulk code generation#26

Merged
JacobCoffee merged 5 commits intomainfrom
feat/voucher-bulk-generate
Feb 14, 2026
Merged

feat: add voucher bulk code generation#26
JacobCoffee merged 5 commits intomainfrom
feat/voucher-bulk-generate

Conversation

@JacobCoffee
Copy link
Owner

@JacobCoffee JacobCoffee commented Feb 14, 2026

Summary

  • Add VoucherBulkConfig dataclass and generate_voucher_codes() service for bulk code generation with configurable prefix, type, count, and constraints
  • Add management dashboard UI (VoucherBulkGenerateView) for bulk generating voucher batches with form validation
  • Codes use cryptographically secure random generation via secrets.token_urlsafe with in-memory uniqueness checks and atomic bulk_create
  • URL mounted at <conference>/vouchers/bulk/generate/ using separate urls_vouchers.py to avoid conflicts
  • "Bulk Generate" button added to existing voucher list page

How to test in the UI

  1. Start the dev server:
    uv run python examples/manage.py migrate
    uv run python examples/manage.py runserver
  2. Log in as a superuser and navigate to the management dashboard
  3. Go to Vouchers for any conference (/manage/<slug>/vouchers/)
  4. Click the "Bulk Generate" button (next to "Add Voucher")
  5. Fill in the form:
    • Prefix: SPEAKER- (or any prefix)
    • Count: 10
    • Type: Complimentary (100% off)
    • Leave other fields as defaults
  6. Submit — you should be redirected to the voucher list with a success message showing "Successfully generated 10 voucher codes"
  7. Verify 10 new vouchers appear in the list, each with code starting with SPEAKER-
  8. Also try the existing "Add Voucher" button to create a single voucher — both flows should work independently

Test plan

  • Bulk generate 10 comp vouchers with prefix "SPEAKER-" and verify all created
  • Verify duplicate codes are prevented across batches
  • Verify form validation (count must be 1-500, prefix required)
  • Verify "Add Voucher" (single creation) still works alongside bulk
  • Verify generated codes appear in the voucher list with correct type/discount

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 14, 2026 01:08
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a management-dashboard workflow for bulk generating voucher codes for a conference, backed by a new registration service that creates voucher batches atomically.

Changes:

  • Introduces VoucherBulkConfig and generate_voucher_codes() to generate batches of vouchers in a transaction.
  • Adds a new management FormView + form + template for bulk generation.
  • Mounts the new route under <conference>/vouchers/bulk/generate/ via a dedicated urls_vouchers.py.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/django_program/registration/services/voucher_service.py New bulk voucher generation service + config dataclass and code generation logic.
src/django_program/manage/views_vouchers.py New management view to render/validate the form and invoke the service.
src/django_program/manage/forms_vouchers.py New form to collect batch generation parameters and optional constraints.
src/django_program/manage/templates/django_program/manage/voucher_bulk_generate.html New dashboard template for bulk voucher generation.
src/django_program/manage/urls_vouchers.py New URLConf for voucher bulk operations.
src/django_program/manage/urls.py Mounts the voucher bulk URLConf under the conference-scoped voucher path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 14, 2026 01:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 14, 2026 02:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…rename)

- Return form_invalid on voucher generation failure instead of redirecting
- Re-fetch vouchers after bulk_create to guarantee PKs on all backends
- Rename test_prefix_filter_optimization to match its actual assertion

Note: PR description mentioned secrets.token_urlsafe but code correctly
uses secrets.choice with uppercase A-Z/0-9 alphabet (from earlier iteration).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JacobCoffee JacobCoffee merged commit f38688e into main Feb 14, 2026
16 checks passed
@JacobCoffee JacobCoffee deleted the feat/voucher-bulk-generate branch February 14, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments