4.2.2.13. Package apps.widgets.raffle

Implements the raffle widget.

4.2.2.13.1. Module apps.widgets.raffle.models

Provides the model for the raffle widget.

apps.widgets.raffle.models.POINTS_PER_TICKET = 25

Number of points required to earn a raffle ticket

class apps.widgets.raffle.models.RafflePrize(*args, **kwargs)[source]

RafflePrize model

Parameters:
  • id (AutoField) – Id
  • round_id (ForeignKey) – The round of the raffle prize.
  • title (CharField) – The title of the raffle prize.
  • value (IntegerField) – The value of the raffle prize
  • description (TextField) – Description of the raffle prize. Uses Markdown formatting.
  • image (ImageField) – A picture of the raffle prize.
  • winner_id (ForeignKey) – The winner of the raffle prize. Normally, this is randomly picked by the system at the end of the round.
add_ticket(user)[source]

Adds a ticket from the user if they have one. Throws an exception if they cannot add a ticket.

allocated_tickets(user=None)[source]

Returns the number of tickets allocated to this prize. Takes an optional argument to return the number of tickets allocated by the user.

remove_ticket(user)[source]

Removes an allocated ticket.

class apps.widgets.raffle.models.RaffleTicket(*args, **kwargs)[source]

Raffle ticket model

Parameters:
  • id (AutoField) – Id
  • user_id (ForeignKey) – User
  • raffle_prize_id (ForeignKey) – Raffle prize
  • created_at (DateTimeField) – Created at
  • updated_at (DateTimeField) – Updated at
static available_tickets(user)[source]

Returns the number of raffle tickets the user has available.

static total_tickets(user)[source]

Return the total tickets available for this user.

4.2.2.13.2. Module apps.widgets.raffle.views

Handle rendering of the raffle widget.

apps.widgets.raffle.views.add_ticket(request, *args, **kwargs)[source]

Adds a user’s raffle ticket to the prize.

apps.widgets.raffle.views.bulk_round_change(request, *args, **kwargs)[source]

Handle change Round for selected Raffle Prizes from the admin interface.

apps.widgets.raffle.views.notify_winner(request, *args, **kwargs)[source]

Sends an email to the user notifying them that they are a winner.

apps.widgets.raffle.views.pick_winner(request, *args, **kwargs)[source]

Picks the raffle game winners for the raffle deadline that has passed.

apps.widgets.raffle.views.prize_summary(request, round_name)[source]

display summary of the winners.

apps.widgets.raffle.views.raffle_form(request, *args, **kwargs)[source]

Supply the raffle form.

apps.widgets.raffle.views.raffle_prize_list(request)[source]

Generates the raffle prize list and renders to page.

apps.widgets.raffle.views.remove_ticket(request, *args, **kwargs)[source]

Removes a user’s raffle ticket from the prize.

apps.widgets.raffle.views.supply(request, page_name)[source]

Supply the view_objects contents, which provides all raffle data.

4.2.2.13.3. Module apps.widgets.raffle.admin

Raffle widget administration

class apps.widgets.raffle.admin.RafflePrizeAdmin(model, admin_site)[source]

raffle admin

change_round(request, queryset)[source]

Change the round for the selected Raffle Prizes.

copy_raffle_prize(request, queryset)[source]

Copies the selected Raffle Prizes.

notice_sent(obj)[source]

return True if the notification had been sent.

notify_winner(request, queryset)[source]

pick winner.

pick_winner(request, queryset)[source]

pick winner.

winner_form(obj)[source]

return the winner and link to pickup form.

class apps.widgets.raffle.admin.RaffleTicketInline(parent_model, admin_site)[source]

SponsorsInline admin.

model

alias of RaffleTicket