django_program.sponsors.views

Views for the sponsors app.

Provides sponsor listing and detail views scoped to a conference via the conference_slug URL kwarg, plus a self-service portal where sponsor contacts can view purchases, download voucher CSVs, and request new bulk purchases.

Classes

BulkPurchaseDetailView

Detail view for a specific bulk purchase.

BulkPurchaseExportCSVView

Export voucher codes for a bulk purchase as a CSV download.

BulkPurchaseRequestView

Form view for sponsors to request a new bulk voucher purchase.

SponsorDetailView

Detail view for a single sponsor.

SponsorListView

List view of all active sponsors for a conference, grouped by level.

SponsorPortalMixin

Permission mixin for the sponsor self-service portal.

SponsorPortalView

Landing page for the sponsor self-service portal.

class django_program.sponsors.views.SponsorListView[source]

Bases: ConferenceMixin, FeatureRequiredMixin, ListView

List view of all active sponsors for a conference, grouped by level.

required_feature: str | tuple[str, ...] = ('sponsors', 'public_ui')
template_name = 'django_program/sponsors/sponsor_list.html'
context_object_name = 'sponsors'
get_queryset()[source]

Return active sponsors for the current conference.

Return type:

QuerySet

Returns:

A queryset of active Sponsor instances ordered by level and name.

get_context_data(**kwargs)[source]

Add sponsor levels to the template context.

Return type:

dict[str, object]

Returns:

Context dict containing conference, sponsors, and levels.

Parameters:

kwargs (object)

class django_program.sponsors.views.SponsorDetailView[source]

Bases: ConferenceMixin, FeatureRequiredMixin, DetailView

Detail view for a single sponsor.

required_feature: str | tuple[str, ...] = ('sponsors', 'public_ui')
template_name = 'django_program/sponsors/sponsor_detail.html'
context_object_name = 'sponsor'
get_object(queryset=None)[source]

Look up the sponsor by conference and slug.

Return type:

Sponsor

Returns:

The matched Sponsor instance.

Raises:

Http404 – If no active sponsor matches the conference and slug.

Parameters:

queryset (QuerySet | None)

get_context_data(**kwargs)[source]

Add benefits to the template context.

Return type:

dict[str, object]

Returns:

Context dict containing conference, sponsor, and benefits.

Parameters:

kwargs (object)

class django_program.sponsors.views.SponsorPortalMixin[source]

Bases: LoginRequiredMixin

Permission mixin for the sponsor self-service portal.

Resolves the conference from the conference_slug URL kwarg and verifies that the authenticated user’s email matches the sponsor’s contact_email, or that the user is staff/superuser.

Sets self.conference and self.sponsor for use by subclasses.

conference: Conference
sponsor: Sponsor
kwargs: dict[str, str]
dispatch(request, *args, **kwargs)[source]

Resolve the conference and sponsor, then enforce access.

Performs conference resolution and sponsor authorization BEFORE calling super().dispatch() so that self.conference and self.sponsor are available when the view method executes.

Parameters:
  • request (HttpRequest) – The incoming HTTP request.

  • *args (str) – Positional arguments from the URL resolver.

  • **kwargs (str) – Keyword arguments from the URL pattern.

Return type:

HttpResponse

Returns:

The HTTP response.

Raises:

PermissionDenied – If the user is not authorized for this sponsor portal.

get_context_data(**kwargs)[source]

Inject conference and sponsor into the template context.

Parameters:

**kwargs (object) – Additional context data.

Return type:

dict[str, object]

Returns:

Context dict with conference and sponsor.

class django_program.sponsors.views.SponsorPortalView[source]

Bases: SponsorPortalMixin, TemplateView

Landing page for the sponsor self-service portal.

Shows sponsor info and a list of all bulk purchases with their current status.

template_name = 'django_program/sponsors/portal_home.html'
get_context_data(**kwargs)[source]

Add bulk purchases to the template context.

Return type:

dict[str, object]

Returns:

Context dict with purchases queryset.

Parameters:

kwargs (object)

class django_program.sponsors.views.BulkPurchaseDetailView[source]

Bases: SponsorPortalMixin, TemplateView

Detail view for a specific bulk purchase.

Shows all voucher codes associated with the purchase along with their redemption counts.

template_name = 'django_program/sponsors/purchase_detail.html'
get_context_data(**kwargs)[source]

Add purchase and voucher details to context.

Return type:

dict[str, object]

Returns:

Context dict with purchase, voucher_links, and summary stats.

Parameters:

kwargs (object)

class django_program.sponsors.views.BulkPurchaseExportCSVView[source]

Bases: SponsorPortalMixin, View

Export voucher codes for a bulk purchase as a CSV download.

get(request, *args, **kwargs)[source]

Generate and return the CSV response.

Parameters:
  • request (HttpRequest) – The incoming HTTP request.

  • *args (str) – Positional arguments from the URL resolver.

  • **kwargs (str) – Keyword arguments from the URL pattern.

Return type:

HttpResponse

Returns:

An HTTP response with CSV content disposition.

class django_program.sponsors.views.BulkPurchaseRequestView[source]

Bases: SponsorPortalMixin, FormView

Form view for sponsors to request a new bulk voucher purchase.

Creates a BulkPurchase in PENDING state for organizer approval.

template_name = 'django_program/sponsors/purchase_request.html'
form_class

alias of BulkPurchaseRequestForm

form_valid(form)[source]

Create a pending BulkPurchase from the form data.

Parameters:

form (BulkPurchaseRequestForm) – The validated form instance.

Return type:

HttpResponse

Returns:

A redirect to the portal home page.