summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-03-28 20:55:02 +0300
committerGitHub <noreply@github.com>2017-03-28 20:55:02 +0300
commit578619d409b4952da34ac5f286c4d80a14b2015d (patch)
tree8c5aec1191ff21975569432a3496dc581f2247b4 /models
parent0c36f5f4c27dce6207b1d8093f387d6a55a6da02 (diff)
parente7fddc2bcb71fca3e806ac75280d5c81dfc1529e (diff)
downloadwekan-578619d409b4952da34ac5f286c4d80a14b2015d.tar.gz
wekan-578619d409b4952da34ac5f286c4d80a14b2015d.tar.bz2
wekan-578619d409b4952da34ac5f286c4d80a14b2015d.zip
Merge pull request #925 from rhelsing/comment-permissions
Comment permissions
Diffstat (limited to 'models')
-rw-r--r--models/boards.js11
-rw-r--r--models/lists.js6
-rw-r--r--models/users.js10
3 files changed, 23 insertions, 4 deletions
diff --git a/models/boards.js b/models/boards.js
index 9323d690..4492d299 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -107,6 +107,7 @@ Boards.attachSchema(new SimpleSchema({
userId: this.userId,
isAdmin: true,
isActive: true,
+ isCommentOnly: false,
}];
}
},
@@ -120,6 +121,9 @@ Boards.attachSchema(new SimpleSchema({
'members.$.isActive': {
type: Boolean,
},
+ 'members.$.isCommentOnly': {
+ type: Boolean,
+ },
permission: {
type: String,
allowedValues: ['public', 'private'],
@@ -219,6 +223,10 @@ Boards.helpers({
return !!_.findWhere(this.members, {userId: memberId, isActive: true, isAdmin: true});
},
+ hasCommentOnly(memberId) {
+ return !!_.findWhere(this.members, {userId: memberId, isActive: true, isAdmin: false, isCommentOnly: true});
+ },
+
absoluteUrl() {
return FlowRouter.url('board', { id: this._id, slug: this.slug });
},
@@ -332,7 +340,7 @@ Boards.mutations({
};
},
- setMemberPermission(memberId, isAdmin) {
+ setMemberPermission(memberId, isAdmin, isCommentOnly) {
const memberIndex = this.memberIndex(memberId);
// do not allow change permission of self
@@ -343,6 +351,7 @@ Boards.mutations({
return {
$set: {
[`members.${memberIndex}.isAdmin`]: isAdmin,
+ [`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
},
};
},
diff --git a/models/lists.js b/models/lists.js
index 682fb096..0ae3ca5f 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -46,13 +46,13 @@ Lists.attachSchema(new SimpleSchema({
Lists.allow({
insert(userId, doc) {
- return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
+ return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
},
update(userId, doc) {
- return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
+ return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
},
remove(userId, doc) {
- return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
+ return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
},
fetch: ['boardId'],
});
diff --git a/models/users.js b/models/users.js
index f944d7b1..edf1a203 100644
--- a/models/users.js
+++ b/models/users.js
@@ -121,6 +121,16 @@ if (Meteor.isClient) {
return board && board.hasMember(this._id);
},
+ isNotCommentOnly() {
+ const board = Boards.findOne(Session.get('currentBoard'));
+ return board && board.hasMember(this._id) && !board.hasCommentOnly(this._id);
+ },
+
+ isCommentOnly() {
+ const board = Boards.findOne(Session.get('currentBoard'));
+ return board && board.hasCommentOnly(this._id);
+ },
+
isBoardAdmin() {
const board = Boards.findOne(Session.get('currentBoard'));
return board && board.hasAdmin(this._id);