Merge branch 'master' into production

This commit is contained in:
Nick Winter 2015-12-07 03:41:59 -08:00
commit a95b938fc5
2 changed files with 7 additions and 5 deletions

View file

@ -296,6 +296,8 @@ CourseInstanceHandler = class CourseInstanceHandler extends Handler
return @sendForbiddenError(res) unless req.user
return @sendBadInputError(res, 'Bad memberID') unless utils.isID classroomID
Classroom.findById classroomID, (err, classroom) =>
return @sendDatabaseError(res, err) if err
return @sendNotFoundError(res) unless classroom
return @sendForbiddenError(res) unless classroom.isMember(req.user._id) or classroom.isOwner(req.user._id)
CourseInstance.find {classroomID: mongoose.Types.ObjectId(classroomID)}, (err, courseInstances) =>
return @sendDatabaseError(res, err) if err

View file

@ -52,14 +52,14 @@ verifyClientResponse = (responseObject, callback) ->
callback null, responseObject
fetchTaskLog = (responseObject, callback) ->
TaskLog.findOne(_id: responseObject.taskID).lean().exec (err, taskLog) =>
TaskLog.findOne(_id: responseObject.taskID).exec (err, taskLog) =>
return callback new Error("Couldn't find TaskLog for _id #{responseObject.taskID}!") unless taskLog
@taskLog = taskLog
callback err, taskLog
checkTaskLog = (taskLog, callback) ->
if taskLog.calculationTimeMS then return callback 'That computational task has already been performed'
if hasTaskTimedOut taskLog.sentDate then return callback 'The task has timed out'
if taskLog.get('calculationTimeMS') then return callback 'That computational task has already been performed'
if hasTaskTimedOut taskLog.get('sentDate') then return callback 'The task has timed out'
callback null
hasTaskTimedOut = (taskSentTimestamp) ->
@ -83,8 +83,8 @@ checkSubmissionDate = (callback) ->
callback null
logTaskComputation = (callback) ->
@taskLog.calculationTimeMS = @clientResponseObject.calculationTimeMS
@taskLog.sessions = @clientResponseObject.sessions
@taskLog.set 'calculationTimeMS', @clientResponseObject.calculationTimeMS
@taskLog.set 'sessions', @clientResponseObject.sessions
@taskLog.save (err, saved) ->
callback err