Fixed a number of bugs; added a few fields.

This commit is contained in:
2022-08-08 22:15:55 -07:00
parent 4560d7203d
commit c96b4a6901
10 changed files with 3791 additions and 160 deletions

View File

@@ -59,13 +59,15 @@ Meteor.methods({
check(assigneeId, String);
check(assigneeType, String);
check(assetId, String);
if(assigneeType !== 'Student' || assigneeType !== 'Staff') {
if(assigneeType !== 'Student' && assigneeType !== 'Staff') {
// Should never happen.
console.error("Error: Received incorrect assignee type in adding an assignment.");
console.error(assigneeType);
}
else if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
AssetAssignments.insert({assetId, assigneeType: assigneeType === "Student" ? 0 : 1, assigneeId});
AssetAssignments.insert({assetId, assigneeType, assigneeId});
}
},
'AssetAssignments.remove'(_id) {

View File

@@ -42,25 +42,27 @@ if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish('assetTypes', function() {
return AssetTypes.find({}, {sort: {name: 1}});
return AssetTypes.find({});
});
}
Meteor.methods({
'assetTypes.add'(name, description) {
'assetTypes.add'(name, description, year) {
check(name, String);
check(description, String);
check(year, String);
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
AssetTypes.insert({name, description});
AssetTypes.insert({name, description, year});
}
},
'assetTypes.update'(_id, name, description) {
'assetTypes.update'(_id, name, description, year) {
check(_id, String);
check(name, String);
check(description, String);
check(year, String);
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
AssetTypes.update({_id}, {$set: {name, description}});
AssetTypes.update({_id}, {$set: {name, description, year}});
}
},
'assetTypes.remove'(_id) {