prevent overlapping classes
This commit is contained in:
parent
d2dbdb0cd3
commit
2bfe58b3f1
@ -175,6 +175,12 @@ Meteor.methods({
|
||||
schools.findOne({
|
||||
name: input.school
|
||||
})) {
|
||||
if (classes.find({
|
||||
status: true,
|
||||
privacy: false,
|
||||
teacher: input.teacher,
|
||||
hour: input.hour
|
||||
}).fetch().length < 1) {
|
||||
input.status = Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']);
|
||||
input.admin = Meteor.userId();
|
||||
Meteor.call('genCode', function(error, result) {
|
||||
@ -190,6 +196,9 @@ Meteor.methods({
|
||||
classes.insert(input, function(err, result) {
|
||||
Meteor.call('joinClass', [result, input.code]);
|
||||
});
|
||||
} else {
|
||||
throw new Meteor.Error("overlap", "This teacher is already teaching a class elsewhere!")
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user