Added requested approval fields and logic

This commit is contained in:
Keith Holliday
2016-10-08 06:29:23 -05:00
parent 393a9290e9
commit f2e5bc52e5
3 changed files with 25 additions and 1 deletions

View File

@@ -316,7 +316,13 @@ api.scoreTask = {
if (!task) throw new NotFound(res.t('taskNotFound'));
if (task.requiresApproval && !task.approved) {
throw new NotAuthorized(res.t('taskRequiresApproval'));
if (task.approvalRequested) {
throw new NotAuthorized(res.t('taskRequiresApproval'));
}
task.approvalRequested = true;
task.approvalRequestedDate = new Date();
await task.save();
return res.respond(200, {message: res.t('taskRequiresApproval'), task});
}
let wasCompleted = task.completed;