Skip to content

Notification Models Documentation

Overview

This document explains the purpose and structure of the NotificationCategory and Notification models in your project. These models enable the creation and management of notifications for vendors, providing important alerts and updates with contextual data.


NotificationCategory Model

The NotificationCategory model defines the different categories or types of notifications that can be generated.

Fields

Field Name Type Description
id Integer (PK) Primary key of the notification category record.
name CharField The name of the notification category (e.g., "Chat", "System Alert", etc.).

Database Table

The NotificationCategory model maps to the m_notification_category table in the database.


Notification Model

The Notification model represents a specific notification sent to a vendor.

Fields

Field Name Type Description
id Integer (PK) Primary key of the notification record.
vendor ForeignKey A reference to the Vendor model, indicating the recipient of the notification.
category ForeignKey A reference to the NotificationCategory model, indicating the category of the notification.
message TextField The content of the notification message.
context_data JSONField A JSON field storing additional context or metadata related to the notification.
is_read BooleanField Indicates whether the notification has been read by the vendor.
is_recent_notification BooleanField Indicates whether the notification is recent or not. Default is True.
readed_at DateTime The timestamp when the notification was read.
created_at DateTime The timestamp when the notification was created.

Validation Rules

  • is_read Default: By default, the is_read field is set to False when the notification is created.
  • context_data Field: The context_data field is optional and can hold any additional data in JSON format relevant to the notification.

Database Table

The Notification model maps to the tbl_notification table in the database.


Relationships

  1. NotificationCategory to Notification: One NotificationCategory can have many Notification records.
  2. Vendor to Notification: Each Notification is associated with one Vendor, representing the recipient of the notification.
  3. Notification to Context Data: The Notification model has an optional context_data field that can hold additional data in JSON format.

Summary

The NotificationCategory and Notification models provide a flexible and structured way to handle notifications within the system. The Notification model is tightly coupled with the Vendor model, ensuring that each notification is directed at a specific vendor and categorized accordingly. The optional context data field enables the inclusion of dynamic information within the notification.