feat(cms): add management for partnerships, history, accreditation, admissions, and policies pages

Implement a singleton page content system to manage static informational pages. This includes:
- New controllers, models, and data files for Partnerships, History, Accreditation, Admissions, and Policies.
- Admin routes and views for updating page content.
- Public API endpoints for fetching page data.
- Migration scripts for initializing page data.
- Updated admin navigation layout to include a dropdown for "About" sections.
- Audit action constants for tracking updates to these pages.
This commit is contained in:
Tống Thành Đạt
2026-04-20 14:08:38 +07:00
parent fab72e86a6
commit 8b6bf5fe6e
48 changed files with 2357 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
const mongoose = require("mongoose");
const jsonHelper = require("../utils/jsonHelper");
function createSingletonPageModel(modelName, collectionName, dataFileName) {
const schema = new mongoose.Schema(
{},
{
strict: false,
timestamps: true,
collection: collectionName,
},
);
schema.statics.getSingle = async function getSingle() {
let doc = await this.findOne();
if (!doc) {
const defaultData = jsonHelper.readJsonFile(dataFileName) || {};
doc = await this.create(defaultData);
}
return doc;
};
return mongoose.model(modelName, schema);
}
module.exports = createSingletonPageModel;