django_program.manage.forms_bulk_purchases

Forms for bulk purchase management in the organizer dashboard.

Classes

BulkPurchaseCreateForm

Form for organizers to create a bulk purchase deal.

class django_program.manage.forms_bulk_purchases.BulkPurchaseCreateForm[source]

Bases: ModelForm

Form for organizers to create a bulk purchase deal.

Product-first layout: what’s being sold, how many codes, what discount, who gets it (optionally a sponsor), and validity window.

class Meta[source]

Bases: object

model

alias of BulkPurchase

fields = ['product_description', 'ticket_type', 'addon', 'quantity', 'unit_price', 'sponsor']
labels = {'addon': 'Add-on', 'product_description': 'Deal name', 'quantity': 'Number of codes', 'sponsor': 'Sponsor', 'ticket_type': 'Ticket type', 'unit_price': 'Price per unit'}
help_texts = {'addon': 'The add-on these voucher codes apply to (e.g. tutorials, t-shirts).', 'product_description': "A short name for this deal, e.g. 'PyCon 2077 Tutorial Bundle', 'Staff T-Shirt Pack'.", 'quantity': 'How many unique voucher codes to generate.', 'sponsor': 'Optionally associate this deal with a sponsor. Leave blank for non-sponsor deals.', 'ticket_type': 'The ticket type these voucher codes apply to.', 'unit_price': 'The price the buyer pays per item (before any voucher discount).'}
widgets = {'product_description': <django.forms.widgets.TextInput object>, 'quantity': <django.forms.widgets.NumberInput object>, 'unit_price': <django.forms.widgets.NumberInput object>}
clean_quantity()[source]

Validate that quantity does not exceed the voucher service limit.

Return type:

int

clean()[source]

Compute total_amount and pack voucher_config from extra fields.

Return type:

dict[str, object]

save(commit=True)[source]

Populate computed fields before saving.

Parameters:

commit (bool)

Return type:

BulkPurchase

base_fields = {'addon': <django.forms.models.ModelChoiceField object>, 'discount_value': <django.forms.fields.DecimalField object>, 'max_uses_per_voucher': <django.forms.fields.IntegerField object>, 'product_description': <django.forms.fields.CharField object>, 'quantity': <django.forms.fields.IntegerField object>, 'sponsor': <django.forms.models.ModelChoiceField object>, 'ticket_type': <django.forms.models.ModelChoiceField object>, 'unit_price': <django.forms.fields.DecimalField object>, 'valid_from': <django.forms.fields.DateTimeField object>, 'valid_until': <django.forms.fields.DateTimeField object>, 'voucher_type': <django.forms.fields.ChoiceField object>}
declared_fields = {'discount_value': <django.forms.fields.DecimalField object>, 'max_uses_per_voucher': <django.forms.fields.IntegerField object>, 'valid_from': <django.forms.fields.DateTimeField object>, 'valid_until': <django.forms.fields.DateTimeField object>, 'voucher_type': <django.forms.fields.ChoiceField object>}
property media

Return all media required to render the widgets on this form.