Merge branch 'improve-announcement' of https://github.com/nztqa/wekan into nztqa-improve-announcement

This commit is contained in:
Lauri Ojansivu 2017-10-01 09:59:57 +03:00
commit d213d37dab
10 changed files with 135 additions and 4 deletions

36
models/announcements.js Normal file
View file

@ -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});
}
});
}