summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-10-01 09:59:57 +0300
committerLauri Ojansivu <x@xet7.org>2017-10-01 09:59:57 +0300
commitd213d37dabe352ededa836ce947b11279704e828 (patch)
tree4d454adf0f80032439ba5f20dc3775d499a1a11d /models
parenta003161fa74a52f8567be6238d6890a88d091d54 (diff)
parenta88ac6113e5f7f428d0f021bbcb213cc517c177e (diff)
downloadwekan-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.js36
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});
+ }
+ });
+}