diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-10-01 09:59:57 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-10-01 09:59:57 +0300 |
commit | d213d37dabe352ededa836ce947b11279704e828 (patch) | |
tree | 4d454adf0f80032439ba5f20dc3775d499a1a11d /models | |
parent | a003161fa74a52f8567be6238d6890a88d091d54 (diff) | |
parent | a88ac6113e5f7f428d0f021bbcb213cc517c177e (diff) | |
download | wekan-d213d37dabe352ededa836ce947b11279704e828.tar.gz wekan-d213d37dabe352ededa836ce947b11279704e828.tar.bz2 wekan-d213d37dabe352ededa836ce947b11279704e828.zip |
Merge branch 'improve-announcement' of https://github.com/nztqa/wekan into nztqa-improve-announcement
Diffstat (limited to 'models')
-rw-r--r-- | models/announcements.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/models/announcements.js b/models/announcements.js new file mode 100644 index 00000000..2cb1e1b7 --- /dev/null +++ b/models/announcements.js @@ -0,0 +1,36 @@ +Announcements = new Mongo.Collection('announcements'); + +Announcements.attachSchema(new SimpleSchema({ + enabled: { + type: Boolean, + defaultValue: false, + }, + title: { + type: String, + optional: true, + }, + body: { + type: String, + optional: true, + }, + sort: { + type: Number, + decimal: true, + }, +})); + +Announcements.allow({ + update(userId) { + const user = Users.findOne(userId); + return user && user.isAdmin; + }, +}); + +if (Meteor.isServer) { + Meteor.startup(() => { + const announcements = Announcements.findOne({}); + if(!announcements){ + Announcements.insert({enabled: false, sort: 0}); + } + }); +} |