reorderClasses

This commit is contained in:
Yaman Qalieh 2016-09-10 12:12:15 -04:00
parent 2908c46452
commit 006f9db206

View File

@ -465,7 +465,7 @@ Meteor.methods({
"__proto__": current.__proto__, "__proto__": current.__proto__,
"school": change.school, "school": change.school,
"grade": change.grade, "grade": change.grade,
"classes": change.classes, "classes": current.classes,
"description": change.description, "description": change.description,
"avatar": change.avatar, "avatar": change.avatar,
"banner": change.banner, "banner": change.banner,
@ -483,6 +483,21 @@ Meteor.methods({
} }
}); });
}, },
'reorderClasses': function(newOrder) {
var current = Meteor.user().profile;
if(newOrder.every(elem => _.contains(current.classes, elem))) {
current.classes = newOrder;
Meteor.users.update({
_id: Meteor.userId()
}, {
$set: {
profile: current
}
});
} else {
throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
}
},
'createProfile': function(userId) { 'createProfile': function(userId) {
var current = Meteor.users.findOne({ var current = Meteor.users.findOne({
_id: userId _id: userId