summaryrefslogtreecommitdiffstats
path: root/models/notices.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/notices.js')
-rw-r--r--models/notices.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/models/notices.js b/models/notices.js
new file mode 100644
index 00000000..d62f6797
--- /dev/null
+++ b/models/notices.js
@@ -0,0 +1,36 @@
+Notices = new Mongo.Collection('notices');
+
+Notices.attachSchema(new SimpleSchema({
+ enabled: {
+ type: Boolean,
+ defaultValue: false,
+ },
+ title: {
+ type: String,
+ optional: true,
+ },
+ body: {
+ type: String,
+ optional: true,
+ },
+ sort: {
+ type: Number,
+ decimal: true,
+ },
+}));
+
+Notices.allow({
+ update(userId) {
+ const user = Users.findOne(userId);
+ return user && user.isAdmin;
+ },
+});
+
+if (Meteor.isServer) {
+ Meteor.startup(() => {
+ const notices = Notices.findOne({});
+ if(!notices){
+ Notices.insert({enabled: false, sort: 0});
+ }
+ });
+}