This commit is contained in:
Kenneth Jao 2016-08-27 01:08:45 -04:00
commit dddfe53c59

View File

@ -33,7 +33,7 @@ for (var i = 0; i < superadmins.length; i++) {
} }
// //
Meteor.publish('schools', function() { Meteor.publish('schools', function() {
return schools.find(); return schools.find();
}); });
@ -88,17 +88,19 @@ Meteor.publish('work', function() {
} else { } else {
userclasses = Meteor.users.findOne(this.userId).profile.classes; userclasses = Meteor.users.findOne(this.userId).profile.classes;
if (userclasses !== undefined) { if (userclasses !== undefined) {
return work.find({ return work.find({
// Only return work of enrolled classes // Only return work of enrolled classes
class: { class: {
$in: Meteor.users.findOne(this.userId).profile.classes $in: Meteor.users.findOne(this.userId).profile.classes
} }
}); });
} else { } else {
Meteor.call('createProfile', this.userId); Meteor.call('createProfile', this.userId);
return classes.find({_id: null}); return classes.find({
} _id: null
});
}
} }
@ -137,7 +139,7 @@ Security.permit(['insert', 'update', 'remove']).collections([schools, classes, w
Meteor.methods({ Meteor.methods({
//Stuff that is accessible in client //Stuff that is accessible in client
//Generates private codes for classes - like google classroom //Generates private codes for classes - like google classroom
'genCode': function() { 'genCode': function() {
currcode = Math.random().toString(36).substr(2, 6); currcode = Math.random().toString(36).substr(2, 6);
@ -435,7 +437,7 @@ Meteor.methods({
throw "Unauthorized"; throw "Unauthorized";
} }
}, },
'toggleWork': function(input) { 'toggleWork': function(input) {
var workobject = work.findOne({ var workobject = work.findOne({
_id: input[0] _id: input[0]