feat: add ci cd files dont edit those files

This commit is contained in:
mahyargdz
2024-10-21 10:22:26 +03:30
commit fb5b440d42
321 changed files with 188273 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
const mongoose = require('mongoose');
function autoPopulateSubs(next) {
this.populate({
path: 'childs',
select: 'title childs navIndex url modelType treeCat parent defaultPageType',
options:{
sort : 'navIndex'
}
// sort: {navIndex: -1},
});
next();
}
function file(file) {
return '/uploads/files/terms/' + file
}
function image(img) {
if (img) return '/uploads/images/category/' + img
else return '/img/no-cover.jpg'
}
const CategoryTermsFile = mongoose.Schema({
file: {type: String, get: file},
title: String
})
const CategorySchema = mongoose.Schema({
title: String,
parent: {type: mongoose.Schema.Types.ObjectId, ref: 'Category', default: null},
childs: [{type: mongoose.Schema.Types.ObjectId, ref: 'Category'}],
treeCat: [{type: mongoose.Schema.Types.ObjectId, ref: 'Category'}],
rootParent: {type: mongoose.Schema.Types.ObjectId, ref: 'Category'},
priority: {type: Number, default: 0},
showInMenu: Boolean,
navIndex: {type: Number, default: null},
news: {type: Boolean, default: true},
child: {type: Boolean, default: true},
special: {type: Boolean, default: false},
allowComment: {type: Boolean, default: false},
level: {type: Number, default: 1},
siteMap: {type: Boolean, default: true},
modelType: String,
_creator: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
_updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
haveNews: {type: Boolean, default: false},
///// for client
hasNewsTab: {type: Boolean, default: true},
hasContentTab: {type: Boolean, default: true},
hasMediaTab: {type: Boolean, default: true},
hasSubMenusTab: {type: Boolean, default: true},
hasTermsTab: {type: Boolean, default: true},
hasNotificationsTab: {type: Boolean, default: true},
hasSpecNewsTab: {type: Boolean, default: true},
hasNazarTab: {type: Boolean, default: true},
hasNewsFileTab: {type: Boolean, default: true},
defaultPageType: {type: String, default: 'news'},
/** page */
showInFooter: {type: Number, enum: [0, 1, 2, 3], default: 0},
url: {type: String, default: null},
pageContent: String,
terms: [CategoryTermsFile],
hasManagerInfo: {type: Boolean, default: true},
managerCover: {type: String, get: image},
managerName: String,
managerDescription: String
});
CategorySchema.index({parent: 1, childs: 1});
CategorySchema
.pre('findOne', autoPopulateSubs)
.pre('find', autoPopulateSubs);
module.exports = mongoose.model('Category', CategorySchema);