Package apps.widgets.notifications

Provides the notification service.


Get the number of notifications that are unread.

apps.widgets.notifications.get_unread_notifications(user, limit=None)[source]

Retrieves the user’s unread notifications that are to be displayed on the web. Returns a dictionary containing their alerts, their unread notifications, and if there are more unread notifications.


Retrieves notifications that should be displayed in an alert. Module apps.widgets.notifications.models

Model definition for notification service.

class apps.widgets.notifications.models.NoticeTemplate(*args, **kwargs)[source]

Templates for built in notifications.

  • id (AutoField) – Id
  • notice_type (SlugField) – Notice type
  • template (TextField) – Uses Markdown formatting. The available template variables are listed here.

Renders the message first using Django’s templating system, then using Markdown. The template renderer uses the passed in context to insert variables.

apps.widgets.notifications.models.TYPE_CHOICES = (('round-transition', 'Round Transition'), ('raffle-winner', 'Raffle Winner'), ('prize-winner', 'Prize Winner'), ('commitment-ready', 'Commitment Ready'), ('prize-winner-receipt', 'Prize Winner Receipt Form'), ('raffle-winner-receipt', 'Raffle Winner Receipt Form'))

Possible notification types.

class apps.widgets.notifications.models.UserNotification(*args, **kwargs)[source]

User Notification

  • id (AutoField) – Id
  • recipient_id (ForeignKey) – The recipient of this notification.
  • contents (TextField) – The content of the notification.
  • unread (BooleanField) – Unread
  • updated_at (DateTimeField) – Updated at
  • created_at (DateTimeField) – Created at
  • level (IntegerField) – The notification level, such as INFO or ERROR.
  • display_alert (BooleanField) – If enabled, display the alert dialog box to user.
  • content_type_id (ForeignKey) – Content type
  • object_id (PositiveIntegerField) – Object id
static create_email_notification(recipient_email, subject, message, html_message=None)[source]

Create an email notification.

static create_error_notification(recipient, contents, display_alert=True, content_object=None)[source]

Create an error level notification.

static create_info_notification(recipient, contents, display_alert=False, content_object=None)[source]

Create an info level notification.

static create_success_notification(recipient, contents, display_alert=False, content_object=None)[source]

Create a success notification.

static create_warning_notification(recipient, contents, display_alert=True, content_object=None)[source]

Create a warning level notification.


Return the css class for the icon.


Return true if success.

save(*args, **kwargs)[source]

Custom save method.


Return the style class Module apps.widgets.notifications.views

Handle the requests for the notification widget.

apps.widgets.notifications.views.read(request, notification_id)[source]

Handle the read notification request.

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

Supply the view_objects content, which are the last 3 unread notifications.