Notifications¶
Users have an inbox at /notifications/; the navigation shows the number
of unread notifications. The platform currently notifies contributors when
a reviewer accepts or rejects their submission.
Sending a notification¶
from baibu.notifications.services import notify
notify(user, kind="submission_accepted", link="/contribute/")
kindnames what the notification is about. Kinds registered inbaibu/notifications/kinds.pyhave translatable texts, rendered when the notification is shown, so each reader sees them in their own language. Parameters go inparamsand fill%(name)splaceholders.- A notification of an unregistered kind shows the
titleandbodypassed tonotify()as they are. linkmust be a path inside the platform (starting with/); anything else is dropped. Opening a notification marks it as read and follows the link.notify()never raises: a failure is logged and the caller's work carries on.
To add a kind in a feature app:
from django.utils.translation import gettext_lazy as _
from baibu.notifications import kinds
kinds.register("event_reminder", title=_("Reminder: %(event)s"), body=_("It starts at %(time)s."))
Retention¶
Read notifications older than NOTIFICATIONS_RETENTION_DAYS are deleted by
a daily Celery beat task. Unread notifications are kept. Deleting a user
deletes their notifications.