From b996fe1a91f9d313abd54a1d8d7b58fbf2236d3a Mon Sep 17 00:00:00 2001 From: david Date: Wed, 9 Oct 2019 22:52:41 +0200 Subject: [PATCH] Poder dejar comentarios en borrador --- helpers/composes.helper.js | 9 ++++++--- modules/comments/comment.model.js | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/helpers/composes.helper.js b/helpers/composes.helper.js index d2ac43d..95c1bbb 100644 --- a/helpers/composes.helper.js +++ b/helpers/composes.helper.js @@ -64,7 +64,7 @@ const locationComposer = (location, context) => { const commentComposer = (comment, context) => { if (comment.user) { - comment.user_name = comment.user.name + '---'; + comment.user_name = comment.user.name + ' ' + comment.user.surname; comment.profile_picture = cdnHelper.getCDNMediaUrl(comment.user.profile_picture); }else { comment.user_name = comment.nameUserOld; @@ -213,6 +213,11 @@ const eventComposer = (event, context) => { multimedias = multimediaComposer(event.multimedias) }; + let comments = []; + if ((context.scopes) && (context.scopes.includes('includeComments'))) { + comments = commentsComposer(event.comments); + }; + let speakers = [] let details = [] if ((context.scopes) && (context.scopes.includes('includeDetails'))) { @@ -233,8 +238,6 @@ const eventComposer = (event, context) => { let partners = getPartnersData(); - console.log(partners); - return Object.assign({}, event, { multimedias: multimedias }, diff --git a/modules/comments/comment.model.js b/modules/comments/comment.model.js index 88749ff..1b533d6 100644 --- a/modules/comments/comment.model.js +++ b/modules/comments/comment.model.js @@ -23,6 +23,11 @@ module.exports = function (sequelize, DataTypes) { profile_pictureOld: { type: DataTypes.STRING(255), }, + state: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: 'draft' + }, }, { indexes: [{ unique: false, @@ -33,6 +38,9 @@ module.exports = function (sequelize, DataTypes) { timestamps: true, defaultScope: { + where: { + state: 'publish', + }, include: [{ model: sequelize.models.User, as: 'user',