Moved approval fields to group subdoc

This commit is contained in:
Keith Holliday
2016-10-22 13:07:26 -05:00
parent d798ebadfe
commit 3ec3722038
7 changed files with 26 additions and 21 deletions

View File

@@ -316,13 +316,13 @@ api.scoreTask = {
if (!task) throw new NotFound(res.t('taskNotFound'));
if (task.requiresApproval && !task.approved) {
if (task.approvalRequested) {
if (task.group.requiresApproval && !task.group.approved) {
if (task.group.approvalRequested) {
throw new NotAuthorized(res.t('taskRequiresApproval'));
}
task.approvalRequested = true;
task.approvalRequestedDate = new Date();
task.group.approvalRequested = true;
task.group.approvalRequestedDate = new Date();
let group = await Group.getGroup({user, groupId: task.group.id, fields: requiredGroupFields});
let groupLeader = await User.findById(group.leader); // Use this method so we can get access to notifications