notifications

The notifications package has an API for sending notifications.

Location: allianceauth.notifications

Example

from allianceauth.notifications.models import Notification

def notify_user_view(request):
    '''Simple view sending a notification to the user'''

    Notification.objects.notify_user(
            user=request.user,
            title="Some title",
            message="Some message",
            level=Notification.Level.INFO,
        )

models

class Notification(*args, **kwargs)[source]

Notification to a user within Auth

Parameters:

Relationship fields:

Parameters:

user (ForeignKey to User) – User (related name: notification)

class Level(*values)[source]

A notification level.

DANGER = 'danger'
INFO = 'info'
SUCCESS = 'success'
WARNING = 'warning'
classmethod from_old_name(name: str) object[source]

Map old name to enum.

Raises ValueError for invalid names.

mark_viewed() None[source]

Mark notification as viewed.

set_level(level_name: str) None[source]

Set notification level according to old level name, e.g. ‘CRITICAL’.

Raises ValueError on invalid level names.

managers

class NotificationManager(*args, **kwargs)[source]
notify_user(user: object, title: str, message: str = None, level: str = 'info') object[source]

Sends a new notification to user. Returns newly created notification object.

user_unread_count(user_pk: int) int[source]

returns the cached unread count for a user given by user PK

Will return -1 if user can not be found