Skip to content

Commit

Permalink
Updates to notifications and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul McCafferty committed Apr 19, 2021
1 parent e28dd99 commit 3983716
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 578 deletions.
25 changes: 20 additions & 5 deletions src/resources/datarequest/datarequest.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ module.exports = {
data = { ...accessRecord.toObject() };
}
// 7. Append question actions depending on user type and application status
data.jsonSchema = datarequestUtil.injectQuestionActions(data.jsonSchema, constants.userTypes.APPLICANT, data.applicationStatus, null, constants.userTypes.APPLICANT);
data.jsonSchema = datarequestUtil.injectQuestionActions(
data.jsonSchema,
constants.userTypes.APPLICANT,
data.applicationStatus,
null,
constants.userTypes.APPLICANT
);
// 8. Return payload
return res.status(200).json({
status: 'success',
Expand Down Expand Up @@ -342,7 +348,13 @@ module.exports = {
data = { ...accessRecord.toObject() };
}
// 8. Append question actions depending on user type and application status
data.jsonSchema = datarequestUtil.injectQuestionActions(data.jsonSchema, constants.userTypes.APPLICANT, data.applicationStatus, null, constants.userTypes.APPLICANT);
data.jsonSchema = datarequestUtil.injectQuestionActions(
data.jsonSchema,
constants.userTypes.APPLICANT,
data.applicationStatus,
null,
constants.userTypes.APPLICANT
);
// 9. Return payload
return res.status(200).json({
status: 'success',
Expand Down Expand Up @@ -1777,8 +1789,8 @@ module.exports = {
// Save new record
await DataRequestModel.create(clonedAccessRecord, saveCallBack);
} else {
let appToCloneInto = await DataRequestModel.findOne({ _id: appIdToCloneInto }).populate([
let appToCloneInto = await DataRequestModel.findOne({ _id: appIdToCloneInto })
.populate([
{
path: 'datasets dataset authors',
},
Expand Down Expand Up @@ -2091,7 +2103,10 @@ module.exports = {
case constants.notificationTypes.SUBMITTED:
// 1. Create notifications
// Custodian notification
if (_.has(accessRecord.datasets[0].toObject(), 'publisher.team.users')) {
if (
_.has(accessRecord.datasets[0].toObject(), 'publisher.team.users') &&
accessRecord.datasets[0].publisher.allowAccessRequestManagement
) {
// Retrieve all custodian user Ids to generate notifications
custodianManagers = teamController.getTeamMembersByRole(accessRecord.datasets[0].publisher.team, constants.roleTypes.MANAGER);
custodianUserIds = custodianManagers.map(user => user.id);
Expand Down
Loading

0 comments on commit 3983716

Please sign in to comment.