Skip to content

Commit 30ea264

Browse files
authored
Merge pull request #837 from topcoder-platform/PM-1499_allow-pm-to-edit
PM-1499 - update opportunity type
2 parents 2071d45 + b7c7f34 commit 30ea264

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/routes/copilotRequest/update.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ module.exports = [
6363
throw err;
6464
}
6565

66+
if (['canceled', 'fulfilled'].includes(copilotRequest.status)) {
67+
const err = new Error(`Copilot request with status ${copilotRequest.status} cannot be updated!`);
68+
err.status = 400;
69+
throw err;
70+
}
71+
6672
// check if same type of copilot request already exists
6773
if (patchData.projectType !== undefined && patchData.projectType !== copilotRequest.data.projectType) {
6874
const sameTypeRequest = await models.CopilotRequest.findOne({
@@ -87,6 +93,11 @@ module.exports = [
8793
}
8894
}
8995

96+
// if type changes, make sure we update "type" on opportunity as well
97+
if (patchData.projectType) {
98+
patchData.type = patchData.projectType;
99+
}
100+
90101
// Only update fields provided in patchData
91102
await copilotRequest.update(_.assign({
92103
data: _.assign(copilotRequest.data, patchData),

0 commit comments

Comments
 (0)