Package apps.widgets.raffle

Implements the raffle widget. 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

  • 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.

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


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


Removes an allocated ticket.

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

Raffle ticket model

  • 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. 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.


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. 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.


return True if the notification had been sent.

notify_winner(request, queryset)[source]

pick winner.

pick_winner(request, queryset)[source]

pick winner.


return the winner and link to pickup form.

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

SponsorsInline admin.


alias of RaffleTicket