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_readDefault: By default, theis_readfield is set toFalsewhen the notification is created.context_dataField: Thecontext_datafield 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
- NotificationCategory to Notification: One
NotificationCategorycan have manyNotificationrecords. - Vendor to Notification: Each
Notificationis associated with oneVendor, representing the recipient of the notification. - Notification to Context Data: The
Notificationmodel has an optionalcontext_datafield 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.