summaryrefslogtreecommitdiffstats
path: root/models/rules.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-09-16 00:10:40 +0300
committerLauri Ojansivu <x@xet7.org>2018-09-16 00:10:40 +0300
commit6673b79738720651f186039808d4e22ef14e4c3c (patch)
tree464eb186f382f14b93c9c9ca7b21a14851746770 /models/rules.js
parent053757f135b54241b4899a83cd3bb749b1e81bc9 (diff)
parent36c04edb9f7cf16fb450b76598c4957968d4674b (diff)
downloadwekan-6673b79738720651f186039808d4e22ef14e4c3c.tar.gz
wekan-6673b79738720651f186039808d4e22ef14e4c3c.tar.bz2
wekan-6673b79738720651f186039808d4e22ef14e4c3c.zip
Merge branch 'feature-rules' of https://github.com/Angtrim/wekan into Angtrim-feature-rules
Diffstat (limited to 'models/rules.js')
-rw-r--r--models/rules.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/models/rules.js b/models/rules.js
new file mode 100644
index 00000000..fe6b04cb
--- /dev/null
+++ b/models/rules.js
@@ -0,0 +1,49 @@
+Rules = new Mongo.Collection('rules');
+
+Rules.attachSchema(new SimpleSchema({
+ title: {
+ type: String,
+ optional: false,
+ },
+ triggerId: {
+ type: String,
+ optional: false,
+ },
+ actionId: {
+ type: String,
+ optional: false,
+ },
+ boardId: {
+ type: String,
+ optional: false,
+ },
+}));
+
+Rules.mutations({
+ rename(description) {
+ return { $set: { description } };
+ },
+});
+
+Rules.helpers({
+ getAction(){
+ return Actions.findOne({_id:this.actionId});
+ },
+ getTrigger(){
+ return Triggers.findOne({_id:this.triggerId});
+ }
+});
+
+
+
+Rules.allow({
+ insert(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ update(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ remove(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ }
+});