Skip to main content

Administrator notifications

Added in 1.0.23

Notifications deliver an announcement to staff and record each recipient's acknowledgement. With AdminSite mounted at /admin/, open /admin/pages/notifications/ or reverse <site-name>:chassis_page_notifications.

Enable the inbox​

Add django_chassis before django.contrib.admin, migrate, and mount a site with ChassisAdminSiteMixin. The inbox follows the users module by default. Set include_global_alerts = True on the site to enable it independently, or False to disable it.

By default, active staff can open their own inbox. Set global_alert_inbox_permission on the site to require an additional permission. Without that permission, the inbox is empty and detail or acknowledgement requests return HTTP 404. Set global_alert_excluded_slugs to omit keys from all inbox sources and the system journal on that site.

Grant operators the appropriate model permissions to manage stored messages: django_chassis.view_globalalert, django_chassis.add_globalalert, django_chassis.change_globalalert, and django_chassis.delete_globalalert. An optional permission on a message restricts its audience. Assign that permission through a group with the default Chassis permission mode.

Publish a stored notification​

Open the Notifications model in Django Admin or run this in python manage.py shell. Replace operator with an active staff login.

from datetime import timedelta

from django.contrib.auth import get_user_model
from django.db import transaction
from django.utils import timezone

from django_chassis.models import GlobalAlert

User = get_user_model()
operator = User.objects.get(**{User.USERNAME_FIELD: 'operator'})

with transaction.atomic():
alert = GlobalAlert.objects.create(
slug='catalog-maintenance-20261125',
title='Catalog maintenance',
message='Order entry closes at 18:00 UTC.',
is_global=False,
expires_at=timezone.now() + timedelta(days=1)
)
alert.recipients.set([operator])
Stored fieldBehavior
slugUnique delivery ID, up to 64 ASCII letters, digits, underscores or hyphens. Keep it stable.
title, messageHeading and body shown to the recipient.
is_global, recipientsDefaults to all eligible staff. With is_global=False, an empty recipient list delivers to nobody.
permissionFull optional permission code, for example orders.view_order.
is_active, expires_atDeactivation or expiration closes the notification.
created_at, orderNew records get a timestamp. Undated provider items sort by order and slug.

Supply notifications from code​

A provider takes a request and yields GlobalAlertDTO objects. Add it to the AdminSite class, or connect a receiver with the signature receiver(sender, request, **kwargs) to collect_global_alerts in django_chassis.services.global_alert_service. Connect receivers once in AppConfig.ready().

from django.contrib.admin import AdminSite

from django_chassis.dto.global_alert import GlobalAlertDTO
from django_chassis.mixins import ChassisAdminSiteMixin


def catalog_alerts(request):
return [
GlobalAlertDTO(
slug='catalog-export-training-20261125',
title='Catalog export training',
message='Open Reports → Catalog exports to try the new workflow.',
permission='orders.view_order'
)
]


class ProjectAdminSite(ChassisAdminSiteMixin, AdminSite):
global_alert_providers = (catalog_alerts,)

The DTO also accepts recipient_ids, is_active, expires_at, order and created_at. Use recipient_ids=None for all eligible staff and an empty collection for no recipients. Use a timezone-aware expiration. Providers run while building admin pages, sometimes several times per request. Keep them fast and free of side effects. Chassis isolates provider exceptions, ignores invalid slugs, and filters permissions and recipients.

Verify delivery and acknowledgement​

  1. Sign in as the selected staff user. The badge counts active unread messages.
  2. Open the row action. Read the message, enter an optional comment and confirm to save the marker. Opening the dialog alone leaves the badge unchanged.
  3. Reload or sign in again. The item remains in the inbox. Repeated submissions preserve the original read time and comment.
  4. Deactivate the announcement or let it expire. It remains in the inbox and contributes zero to the badge. Acknowledging a closed or inaccessible item returns HTTP 404.

Active unread items appear first, then the remaining visible items. Dated items in each group appear newest first. A read marker applies to the same recipient and slug across all sources. Assign a fresh slug to each delivery. Keep emitting a closed provider item to retain it in the inbox.

System notification journal​

See the system journal guide for publishing and closing persistent notices and granting access to the read-only journal.