finished createClass function
This commit is contained in:
parent
09346b1c6c
commit
51ab3c27ed
@ -12,14 +12,34 @@ Meteor.methods({
|
|||||||
},
|
},
|
||||||
//No Security
|
//No Security
|
||||||
'createClass': function(input) {
|
'createClass': function(input) {
|
||||||
// if(Meteor.user() != null && classes.find({status:true, admin:Meteor.userId()}).length < 5 &&
|
var distinctEntries = _.uniq(classes.find({}, {
|
||||||
// schools.find({name:input.school}).fetch().length > 0){
|
sort: {teacher: 1}, fields: {teacher: true}
|
||||||
// classes.schema.validate(input);
|
}).fetch().map(function(x) {
|
||||||
|
return x.teacher;
|
||||||
|
}), true);
|
||||||
|
classes.schema.validate(input);
|
||||||
|
if(Meteor.user() != null && classes.find({status:false, admin:Meteor.userId()}).length < 5 &&
|
||||||
|
schools.find({name:input.school}).fetch().length > 0 && input.status === true) {
|
||||||
|
|
||||||
|
input.subscribers = 0;
|
||||||
|
input.admin = Meteor.userId()
|
||||||
|
if (input.privacy) {
|
||||||
|
input.code = genCode();
|
||||||
|
} else {
|
||||||
|
input.code = "";
|
||||||
|
}
|
||||||
|
if (input.category != "class" && input.category != "club") {
|
||||||
|
input.category = "other";
|
||||||
|
}
|
||||||
|
input.moderators = []
|
||||||
|
input.banned = []
|
||||||
|
input.blockEdit = []
|
||||||
classes.insert(input);
|
classes.insert(input);
|
||||||
// return 1;
|
joinClass(input.name, input.code)
|
||||||
// } else {
|
return 1;
|
||||||
// return 0;
|
} else {
|
||||||
// }
|
return 0;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'editProfile': function(change) {
|
'editProfile': function(change) {
|
||||||
current = Meteor.user().profile;
|
current = Meteor.user().profile;
|
||||||
@ -34,7 +54,7 @@ Meteor.methods({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'joinClass': function(change, pass) {
|
'joinClass': function(change, pass) {
|
||||||
found = classes.find({name: change}).fetch();
|
found = classes.find({name: change, status: true}).fetch();
|
||||||
if (Meteor.user() != null && found.length > 0 && pass === found[0].code) {
|
if (Meteor.user() != null && found.length > 0 && pass === found[0].code) {
|
||||||
current = Meteor.user().profile;
|
current = Meteor.user().profile;
|
||||||
current.classes.append(change);
|
current.classes.append(change);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user