mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-08-04 22:51:03 +02:00
feat(torrents): model torrent add Thumb Schema field
This commit is contained in:
2
config/env/torrents.js
vendored
2
config/env/torrents.js
vendored
@@ -47,7 +47,7 @@ module.exports = {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
thumbsUpScore:{
|
||||
thumbsUpScore: {
|
||||
torrent: 10,
|
||||
topic: 10
|
||||
}
|
||||
|
||||
@@ -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}})</i>
|
||||
>({{vm.topic._thumbs.length}})</i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -128,12 +128,12 @@
|
||||
</ol>
|
||||
</div>
|
||||
<div class="thumbs-up-list"
|
||||
ng-if="vm.topic._scoreList.length && vm.forumsConfig.show_thumbs_up_user_list">
|
||||
ng-if="vm.topic._thumbs.length && vm.forumsConfig.show_thumbs_up_user_list">
|
||||
<div class="thumbs-header" translate="FORUMS.THUMBS_LIST_HEADER"
|
||||
translate-values="{number: vm.topic._scoreList.length}"></div>
|
||||
translate-values="{number: vm.topic._thumbs.length}"></div>
|
||||
<div class="thumbs-users panel-collapsed" id="thumbs-{{vm.topic._id}}">
|
||||
<span class="thumbs-item"
|
||||
ng-repeat="sl in vm.topic._scoreList track by $index"
|
||||
ng-repeat="sl in vm.topic._thumbs track by $index"
|
||||
user-info="sl.user" info-name></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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}})</i>
|
||||
>({{rep._thumbs.length}})</i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="reply-floor">F{{ (vm.currentPage-1) * vm.itemsPerPage + $index + 1 }}</div>
|
||||
@@ -199,12 +199,12 @@
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="thumbs-up-list" ng-if="rep._scoreList.length && vm.forumsConfig.show_thumbs_up_user_list">
|
||||
<div class="thumbs-up-list" ng-if="rep._thumbs.length && vm.forumsConfig.show_thumbs_up_user_list">
|
||||
<div class="thumbs-header" translate="FORUMS.THUMBS_LIST_HEADER"
|
||||
translate-values="{number: rep._scoreList.length}"></div>
|
||||
translate-values="{number: rep._thumbs.length}"></div>
|
||||
<div class="thumbs-users panel-collapsed" id="thumbs-{{rep._id}}">
|
||||
<span class="thumbs-item"
|
||||
ng-repeat="sl in rep._scoreList track by $index"
|
||||
ng-repeat="sl in rep._thumbs track by $index"
|
||||
user-info="sl.user" info-name></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user