diff --git a/config/env/torrents.js b/config/env/torrents.js index 002c7910..bfe79e5a 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -294,13 +294,13 @@ module.exports = { * @name: action name * @value: action score value * @enable: action enable status, if false, system will not change user`s score at this action - * @thumbsUpScore: thumbs up score setting - * @torrent: thumbs up of torrent score change value - * @topic: thumbs up of forum topic/reply score change value + * NOTE: ENABLE VALUE OF DEFAULTACTION MUST BE TRUE */ score: { levelStep: 500, action: { + defaultAction: {name: 'defaultAction', value: 0, enable: true}, + signEveryday: {name: 'signEveryday', value: 10, enable: true}, uploadTorrent: {name: 'uploadTorrent', value: 50, enable: true}, uploadTorrentBeDeleted: {name: 'uploadTorrentBeDeleted', value: -50, enable: true}, @@ -308,7 +308,12 @@ module.exports = { uploadSubtitle: {name: 'uploadSubtitle', value: 20, enable: true}, uploadSubtitleBeDeleted: {name: 'uploadSubtitleBeDeleted', value: -20, enable: true}, - postRequest: {name: 'postRequest', value: -100, enable: true}, //value used requests.scoreForAddRequest, default -100 + thumbsUpScoreOfTorrentFrom: {name: 'thumbsUpScoreOfTorrentFrom', value: -10, enable: true}, + thumbsUpScoreOfTorrentTo: {name: 'thumbsUpScoreOfTorrentTo', value: 10, enable: true}, + thumbsUpScoreOfTopicFrom: {name: 'thumbsUpScoreOfTopicFrom', value: -10, enable: true}, + thumbsUpScoreOfTopicTo: {name: 'thumbsUpScoreOfTopicTo', value: 10, enable: true}, + + postRequest: {name: 'postRequest', value: 0, enable: true}, //value used requests.scoreForAddRequest seedUpDownload: { name: 'seedUpDownload', @@ -342,10 +347,6 @@ module.exports = { enable: true } - }, - thumbsUpScore: { - torrent: 10, - topic: 10 } }, diff --git a/config/lib/score.js b/config/lib/score.js index e1f387a1..c0628667 100644 --- a/config/lib/score.js +++ b/config/lib/score.js @@ -2,11 +2,13 @@ var path = require('path'), config = require(path.resolve('./config/config')), + common = require(path.resolve('./config/lib/common')), mongoose = require('mongoose'), User = mongoose.model('User'), traceLogCreate = require(path.resolve('./config/lib/tracelog')).create; var traceConfig = config.meanTorrentConfig.trace; +var examinationConfig = config.meanTorrentConfig.examination; /** * update @@ -17,15 +19,27 @@ var traceConfig = config.meanTorrentConfig.trace; * @param value */ module.exports.update = function (req, user, action, value) { + var v = value || action.value; + if (action.enable) { if (user) { - user.update({ - $inc: {score: value || action.value} - }).exec(); + if (common.examinationIsValid(user)) { + user.examinationData.score = user.examinationData.score || 0; + user.examinationData.score += v; + + var uploadFinished = user.examinationData.uploaded >= examinationConfig.incrementData.upload; + var downloadFinished = user.examinationData.downloaded >= examinationConfig.incrementData.download; + var scoreFinished = user.examinationData.score >= examinationConfig.incrementData.score; + user.examinationData.isFinished = uploadFinished && downloadFinished && scoreFinished; + user.markModified('examinationData'); + } + user.score += v; + user.save(); traceLogCreate(req, traceConfig.action.userScoreChange, { user: user._id, - score: value || action.value + score: v, + scoreActionName: action.name }); } } diff --git a/modules/forums/client/views/topic.client.view.html b/modules/forums/client/views/topic.client.view.html index de707d30..50352f16 100644 --- a/modules/forums/client/views/topic.client.view.html +++ b/modules/forums/client/views/topic.client.view.html @@ -121,7 +121,7 @@ @@ -203,7 +203,7 @@ diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js index 0a22dd4b..fbf7449f 100644 --- a/modules/forums/server/controllers/forums.server.controller.js +++ b/modules/forums/server/controllers/forums.server.controller.js @@ -16,10 +16,11 @@ var path = require('path'), Reply = mongoose.model('Reply'), Thumb = mongoose.model('Thumb'), async = require('async'), + scoreUpdate = require(path.resolve('./config/lib/score')).update, traceLogCreate = require(path.resolve('./config/lib/tracelog')).create; var traceConfig = config.meanTorrentConfig.trace; -var thumbsUpScore = config.meanTorrentConfig.score.thumbsUpScore; +var scoreConfig = config.meanTorrentConfig.score; var serverMessage = require(path.resolve('./config/lib/server-message')); var serverNoticeConfig = config.meanTorrentConfig.serverNotice; var itemsPerPageConfig = config.meanTorrentConfig.itemsPerPage; @@ -709,8 +710,7 @@ exports.thumbsUp = function (req, res) { var replyUid = undefined; var thumb = new Thumb(); thumb.user = req.user; - thumb.score = thumbsUpScore.topic; - + thumb.score = scoreConfig.action.thumbsUpScoreOfTopicTo.value; if (req.query.replyId) { topic._replies.forEach(function (r) { @@ -728,11 +728,9 @@ exports.thumbsUp = function (req, res) { message: 'SERVER.ALREADY_THUMBS_UP' }); } else { - if (req.user.score >= thumbsUpScore.topic) { + if (req.user.score >= thumb.score) { r._thumbs.push(thumb); - r.user.update({ - $inc: {score: thumbsUpScore.topic} - }).exec(); + scoreUpdate(req, r.user, scoreConfig.action.thumbsUpScoreOfTopicTo); save(); //add server message @@ -767,11 +765,9 @@ exports.thumbsUp = function (req, res) { message: 'SERVER.ALREADY_THUMBS_UP' }); } else { - if (req.user.score >= thumbsUpScore.topic) { + if (req.user.score >= thumb.score) { topic._thumbs.push(thumb); - topic.user.update({ - $inc: {score: thumbsUpScore.topic} - }).exec(); + scoreUpdate(req, topic.user, scoreConfig.action.thumbsUpScoreOfTopicTo); save(); //add server message @@ -803,9 +799,7 @@ exports.thumbsUp = function (req, res) { } }); - user.update({ - $inc: {score: -thumbsUpScore.topic} - }).exec(); + scoreUpdate(req, user, scoreConfig.action.thumbsUpScoreOfTopicFrom); } }; diff --git a/modules/torrents/client/views/view-torrent.client.view.html b/modules/torrents/client/views/view-torrent.client.view.html index 62714604..438d0e76 100644 --- a/modules/torrents/client/views/view-torrent.client.view.html +++ b/modules/torrents/client/views/view-torrent.client.view.html @@ -973,7 +973,7 @@

{{'THUMBS_UP_TORRENT' | translate: ({number: vm.scoreConfig.thumbsUpScore.torrent}) }} + ng-click="vm.beginThumbsUp(vm.torrentLocalInfo);">{{'THUMBS_UP_TORRENT' | translate: ({number: vm.scoreConfig.action.thumbsUpScoreOfTorrentTo.value}) }}

diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js index 1699c0be..5baaa36e 100644 --- a/modules/torrents/server/controllers/torrents.server.controller.js +++ b/modules/torrents/server/controllers/torrents.server.controller.js @@ -35,7 +35,6 @@ var path = require('path'), var traceConfig = config.meanTorrentConfig.trace; var scoreConfig = config.meanTorrentConfig.score; -var thumbsUpScore = config.meanTorrentConfig.score.thumbsUpScore; var ircConfig = config.meanTorrentConfig.ircAnnounce; var itemsPerPageConfig = config.meanTorrentConfig.itemsPerPage; var vsprintf = require('sprintf-js').vsprintf; @@ -935,7 +934,7 @@ exports.thumbsUp = function (req, res) { var torrent = req.torrent; var thumb = new Thumb(); thumb.user = req.user; - thumb.score = thumbsUpScore.torrent; + thumb.score = scoreConfig.action.thumbsUpScoreOfTorrentTo.value; //check if already exist exist = false; @@ -949,11 +948,9 @@ exports.thumbsUp = function (req, res) { message: 'SERVER.ALREADY_THUMBS_UP' }); } else { - if (req.user.score >= thumbsUpScore.torrent) { + if (req.user.score >= thumb.score) { torrent._thumbs.push(thumb); - torrent.user.update({ - $inc: {score: thumbsUpScore.torrent} - }).exec(); + scoreUpdate(req, torrent.user, scoreConfig.action.thumbsUpScoreOfTorrentTo); save(); //add server message @@ -983,9 +980,7 @@ exports.thumbsUp = function (req, res) { } }); - user.update({ - $inc: {score: -thumbsUpScore.torrent} - }).exec(); + scoreUpdate(req, user, scoreConfig.action.thumbsUpScoreOfTorrentFrom); } };