19 lines
733 B
JavaScript
Raw Normal View History

Chromebooks = new Mongo.Collection("chromebook");
Chromebooks.allow({
insert: function (userId, doc) {
return Roles.userIsInRole(userId, ['admin']);
},
2015-02-01 23:24:28 -05:00
update: function (userId, doc) {
2015-02-01 23:34:58 -05:00
if ((Chromebooks.findOne({userid: Meteor.userId()}) === undefined)
|| (Roles.userIsInRole(Meteor.userId(), ['admin', 'teacher']))) {
Chromebooks.update(this._id, {$set: {status: 1}});
Chromebooks.update(this._id, {$set: {last_checkout: new Date()}});
Chromebooks.update(this._id, {$set: {userid: Meteor.userId()}});
Chromebooks.update(this._id, {$set: {user: Meteor.user().profile.name}});
}
2015-02-01 23:24:28 -05:00
},
remove: function (userId, doc) {
return Roles.userIsInRole(userId, ['admin']);
},
2015-02-01 23:27:08 -05:00
fetch: []
});