Initial cut - untested.
This commit is contained in:
@@ -17,17 +17,17 @@ if (Meteor.isServer) {
|
||||
});
|
||||
}
|
||||
Meteor.methods({
|
||||
'staff.add'(id, firstName, lastName, email, siteId) {
|
||||
async 'staff.add'(id, firstName, lastName, email, siteId) {
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
Staff.insert({id, firstName, lastName, email, siteId});
|
||||
await Staff.insertAsync({id, firstName, lastName, email, siteId});
|
||||
}
|
||||
},
|
||||
'staff.update'(_id, id, firstName, lastName, email, siteId) {
|
||||
async 'staff.update'(_id, id, firstName, lastName, email, siteId) {
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
Staff.update({_id}, {$set: {id, firstName, lastName, email, siteId}});
|
||||
await Staff.updateAsync({_id}, {$set: {id, firstName, lastName, email, siteId}});
|
||||
}
|
||||
},
|
||||
'staff.remove'(_id) {
|
||||
async 'staff.remove'(_id) {
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
//TODO: Need to first verify there are no checked out assets to the staff member.
|
||||
}
|
||||
@@ -52,12 +52,12 @@ Meteor.methods({
|
||||
* StuEmail,Student ID,First Name,Last Name,Grade,First Name Alias,Last Name Alias
|
||||
* @type: Currently only supports 'CSV' or 'Aeries Text Report'
|
||||
*/
|
||||
'staff.loadCsv'(csv, type, siteId) {
|
||||
async 'staff.loadCsv'(csv, type, siteId) {
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
check(csv, String);
|
||||
check(siteId, String);
|
||||
|
||||
let site = Sites.findOne({_id: siteId});
|
||||
let site = await Sites.findOneAsync({_id: siteId});
|
||||
|
||||
if(site) {
|
||||
let cleanCsv;
|
||||
@@ -107,8 +107,8 @@ Meteor.methods({
|
||||
|
||||
const bound = Meteor.bindEnvironment((callback) => {callback();});
|
||||
|
||||
parse(cleanCsv, {}, function(err, records) {
|
||||
bound(() => {
|
||||
parse(cleanCsv, {}, async function(err, records) {
|
||||
bound(async () => {
|
||||
if(err) console.error(err);
|
||||
else {
|
||||
let foundIds = new Set();
|
||||
@@ -138,7 +138,7 @@ Meteor.methods({
|
||||
|
||||
//console.log(staff);
|
||||
try {
|
||||
Staff.upsert({id: staff.id}, {$set: staff});
|
||||
await Staff.upsertAsync({id: staff.id}, {$set: staff});
|
||||
}
|
||||
catch(err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user