mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
add: more commits
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/***********************************************************************************************************************************************************************
|
||||
* File Name: notification_template.mdl.js
|
||||
* Type of Program: Model
|
||||
* Description: Admin-managed catalog of system-triggered notification wording
|
||||
* (title + message). Mirrors models/email_templates/email_templates.mdl.js.
|
||||
* `is_system` rows are the built-in types referenced by `type` from
|
||||
* services/notificationTemplate.service.js's renderNotification()
|
||||
* callers (cron jobs, controllers) — protected from deletion by the
|
||||
* admin controller (no create/delete endpoint at all, since a new
|
||||
* type needs a code call site before it means anything).
|
||||
*
|
||||
* Publish workflow: `title`/`message` are the LIVE content — the
|
||||
* only columns renderNotification() ever reads. Editing a 'sent'
|
||||
* template writes to `draft_title`/`draft_message` instead, leaving
|
||||
* live content untouched until an admin explicitly publishes again
|
||||
* (see controllers/admin/notification_templates.controller.js).
|
||||
*
|
||||
* Author: Kenneth Obsequio (@lash0000)
|
||||
* Date Created: Jul. 3, 2026
|
||||
***********************************************************************************************************************************************************************/
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../../config/db.config');
|
||||
|
||||
const mdl_NotificationTemplate = sequelize.define('NotificationTemplate', {
|
||||
notification_template_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: 'ID', hidden: true, order: 0 },
|
||||
type: { type: DataTypes.STRING(100), allowNull: false, unique: true, label: 'Type', hidden: false, order: 1, filterable: true },
|
||||
// Written into the delivered admin_notifications/user_notifications row's own
|
||||
// `type` column (e.g. 'task', 'course', 'announcement') — distinct from the
|
||||
// lookup key above, since several lookup keys share the same delivered type.
|
||||
notify_type: { type: DataTypes.STRING(64), allowNull: false, label: 'Notify Type', hidden: false, order: 2, filterable: true },
|
||||
scope: { type: DataTypes.ENUM('admin', 'user', 'both'), allowNull: false, label: 'Scope', hidden: false, order: 3, filterable: true },
|
||||
label: { type: DataTypes.STRING(150), allowNull: false, label: 'Label', hidden: false, order: 4, filterable: true },
|
||||
status: { type: DataTypes.ENUM('draft', 'sent'), allowNull: false, defaultValue: 'draft', label: 'Status', hidden: false, order: 5, filterable: true },
|
||||
title: { type: DataTypes.STRING(255), allowNull: true, label: 'Title', hidden: false, order: 6, filterable: false },
|
||||
message: { type: DataTypes.TEXT, allowNull: true, label: 'Message', hidden: false, order: 7, filterable: false },
|
||||
draft_title: { type: DataTypes.STRING(255), allowNull: true, label: 'Draft Title', hidden: false, order: 8, filterable: false },
|
||||
draft_message: { type: DataTypes.TEXT, allowNull: true, label: 'Draft Message', hidden: false, order: 9, filterable: false },
|
||||
last_sent_at: { type: DataTypes.DATE, allowNull: true, label: 'Last Published', hidden: false, order: 10, filterable: false },
|
||||
is_system: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, label: 'System', hidden: false, order: 11, filterable: true },
|
||||
}, {
|
||||
tableName: 'notification_templates',
|
||||
timestamps: true,
|
||||
paranoid: false,
|
||||
});
|
||||
|
||||
module.exports = mdl_NotificationTemplate;
|
||||
Reference in New Issue
Block a user