diff --git a/config/env/torrents.js b/config/env/torrents.js index 942c0c8c..4f911928 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -47,7 +47,7 @@ module.exports = { enable: true } }, - thumbsUpScore:{ + thumbsUpScore: { torrent: 10, topic: 10 } diff --git a/modules/forums/client/views/topic.client.view.html b/modules/forums/client/views/topic.client.view.html index 66bd481c..d14bca5e 100644 --- a/modules/forums/client/views/topic.client.view.html +++ b/modules/forums/client/views/topic.client.view.html @@ -105,7 +105,7 @@ mt-scale-by-param="{scale: 3, duration: '.5s'}" mt-scale-start="false" title="{{'FORUMS.TITLES.TOPIC_THUMBS_UP' | translate: ({number: vm.forumsConfig.thumbs_up_score}) }}" - >({{vm.topic._scoreList.length}}) + >({{vm.topic._thumbs.length}}) @@ -128,12 +128,12 @@
+ ng-if="vm.topic._thumbs.length && vm.forumsConfig.show_thumbs_up_user_list">
+ translate-values="{number: vm.topic._thumbs.length}">
@@ -178,7 +178,7 @@ mt-scale-by-param="{scale: 3, duration: '.5s'}" mt-scale-start="false" title="{{'FORUMS.TITLES.TOPIC_THUMBS_UP' | translate: ({number: vm.forumsConfig.thumbs_up_score}) }}" - >({{rep._scoreList.length}}) + >({{rep._thumbs.length}})
F{{ (vm.currentPage-1) * vm.itemsPerPage + $index + 1 }}
@@ -199,12 +199,12 @@ -
+
+ translate-values="{number: rep._thumbs.length}">
diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js index eef6aa52..e28cbc60 100644 --- a/modules/forums/server/controllers/forums.server.controller.js +++ b/modules/forums/server/controllers/forums.server.controller.js @@ -517,7 +517,7 @@ exports.thumbsUp = function (req, res) { if (r._id.equals(req.query.replyId)) { //check if already exist exist = false; - r._scoreList.forEach(function (sr) { + r._thumbs.forEach(function (sr) { if (sr.user._id.equals(req.user._id)) { exist = true; } @@ -528,7 +528,7 @@ exports.thumbsUp = function (req, res) { }); } else { if (req.user.score >= thumbsUpScore.topic) { - r._scoreList.push(thumb); + r._thumbs.push(thumb); r.user.update({ $inc: {score: thumbsUpScore.topic} }).exec(); @@ -544,7 +544,7 @@ exports.thumbsUp = function (req, res) { } else { //check if already exist exist = false; - topic._scoreList.forEach(function (sr) { + topic._thumbs.forEach(function (sr) { if (sr.user._id.equals(req.user._id)) { exist = true; } @@ -555,7 +555,7 @@ exports.thumbsUp = function (req, res) { }); } else { if (req.user.score >= thumbsUpScore.topic) { - topic._scoreList.push(thumb); + topic._thumbs.push(thumb); topic.user.update({ $inc: {score: thumbsUpScore.topic} }).exec(); @@ -937,10 +937,10 @@ exports.topicById = function (req, res, next, id) { .populate('user', 'username displayName profileImageURL uploaded downloaded score') .populate('lastUser', 'username displayName profileImageURL uploaded downloaded') .populate('updatedBy', 'username displayName profileImageURL uploaded downloaded') - .populate('_scoreList.user', 'username displayName profileImageURL uploaded downloaded') + .populate('_thumbs.user', 'username displayName profileImageURL uploaded downloaded') .populate('_replies.user', 'username displayName profileImageURL uploaded downloaded') .populate('_replies.updatedBy', 'username displayName profileImageURL uploaded downloaded') - .populate('_replies._scoreList.user', 'username displayName profileImageURL uploaded downloaded') + .populate('_replies._thumbs.user', 'username displayName profileImageURL uploaded downloaded') .exec(function (err, topic) { if (err) { return next(err); diff --git a/modules/forums/server/models/topic.server.model.js b/modules/forums/server/models/topic.server.model.js index c2caa697..baf67bd3 100644 --- a/modules/forums/server/models/topic.server.model.js +++ b/modules/forums/server/models/topic.server.model.js @@ -62,7 +62,7 @@ var ReplySchema = new Schema({ }, _attach: [AttachSchema], - _scoreList: [ThumbSchema], + _thumbs: [ThumbSchema], updatedAt: { type: Date @@ -115,7 +115,7 @@ var TopicSchema = new Schema({ }, _replies: [ReplySchema], _attach: [AttachSchema], - _scoreList: [ThumbSchema], + _thumbs: [ThumbSchema], isTop: { type: Boolean, diff --git a/modules/torrents/server/models/torrent.server.model.js b/modules/torrents/server/models/torrent.server.model.js index f693b3ee..161869cd 100644 --- a/modules/torrents/server/models/torrent.server.model.js +++ b/modules/torrents/server/models/torrent.server.model.js @@ -35,6 +35,23 @@ var CommentSchema = new Schema({ } }); +/** + * Sub Thumb Schema + */ +var ThumbSchema = new Schema({ + user: { + type: Schema.Types.ObjectId, + ref: 'User' + }, + score: { + type: Number, + default: 0 + }, + createdAt: { + type: Date, + default: Date.now + } +}); /** * Torrent Schema @@ -129,6 +146,7 @@ var TorrentSchema = new Schema({ type: Date, default: Date.now }, + _thumbs: [ThumbSchema], _other_torrents: [], //resource info