Initial cut - untested.

This commit is contained in:
2025-09-25 09:31:02 -07:00
parent 7a0666cc6c
commit 3775522265
33 changed files with 351 additions and 346 deletions

View File

@@ -13,25 +13,25 @@ if (Meteor.isServer) {
});
}
Meteor.methods({
'sites.update'(_id, name, externalId) {
async 'sites.update'(_id, name, externalId) {
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
Sites.update({_id}, {$set: {name, externalId}});
await Sites.updateAsync({_id}, {$set: {name, externalId}});
}
},
'sites.add'(name, externalId) {
async 'sites.add'(name, externalId) {
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
Sites.insert({name, externalId});
await Sites.insertAsync({name, externalId});
}
},
'sites.remove'(_id) {
async 'sites.remove'(_id) {
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
let site = Sites.find({_id});
let site = await Sites.findOneAsync({_id});
if(site) {
//Clear any site references in student/room entries.
Students.update({siteId: _id}, {$unset: {siteId: 1}});
Staff.update({siteId: _id}, {$unset: {siteId: 1}});
Sites.remove({_id});
await Students.updateAsync({siteId: _id}, {$unset: {siteId: 1}});
await Staff.updateAsync({siteId: _id}, {$unset: {siteId: 1}});
await Sites.removeAsync({_id});
}
}
},