blog
This commit is contained in:
parent
4af14ffb22
commit
5558ea1684
@ -45,13 +45,15 @@ routes.get('/admin/posts',
|
|||||||
isAdministratorUser,
|
isAdministratorUser,
|
||||||
SortMiddleware.middleware({ default: "-date" }),
|
SortMiddleware.middleware({ default: "-date" }),
|
||||||
blogController.find({
|
blogController.find({
|
||||||
scopes: ['includeAllStates'],
|
scopes: ['includeMultimedias', 'includeCategories'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
routes.get('/admin/posts/:id', isLoggedUser,
|
routes.get('/admin/posts/:id', isLoggedUser,
|
||||||
isAdministratorUser,
|
isAdministratorUser,
|
||||||
blogController.findOne()
|
blogController.findOne({
|
||||||
|
scopes: ['includeMultimedias', 'includeCategories'],
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
routes.get('/admin/posts/:id/comments', isLoggedUser,
|
routes.get('/admin/posts/:id/comments', isLoggedUser,
|
||||||
|
|||||||
@ -20,13 +20,17 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
|
summary: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
content: {
|
content: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false
|
allowNull: true
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
@ -65,14 +69,15 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
foreignKey: 'entityId',
|
foreignKey: 'entityId',
|
||||||
as: { singular: 'comment', plural: 'comments' }
|
as: { singular: 'comment', plural: 'comments' }
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.addScope('includeAllStates', () => {
|
Post.addScope('includeCategories', () => {
|
||||||
return {
|
return {
|
||||||
where: {
|
include: [{
|
||||||
state: ['publish', 'draft']
|
model: sequelize.models.Category,
|
||||||
},
|
as: 'categories',
|
||||||
|
required: false,
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user