Skip to content

Commit 25bd0e5

Browse files
authored
Merge pull request #719 from topcoder-platform/master
Dev - sync with master
2 parents 79c1068 + c2dd1ed commit 25bd0e5

File tree

6 files changed

+272
-1253
lines changed

6 files changed

+272
-1253
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ workflows:
8686
branches:
8787
only:
8888
- dev
89-
- feature/top-262-projectid-non-mandatory
9089

9190
- "build-qa":
9291
context: org-global

config/default.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,4 @@ module.exports = {
130130
GRPC_CHALLENGE_SERVER_PORT: process.env.GRPC_DOMAIN_CHALLENGE_SERVER_PORT || 8888,
131131
GRPC_ACL_SERVER_HOST: process.env.GRPC_ACL_SERVER_HOST || "localhost",
132132
GRPC_ACL_SERVER_PORT: process.env.GRPC_ACL_SERVER_PORT || 8889,
133-
134-
SKIP_PROJECT_ID_BY_TIMLINE_TEMPLATE_ID: process.env.SKIP_PROJECT_ID_BY_TIMLINE_TEMPLATE_ID || '517e76b0-8824-4e72-9b48-a1ebde1793a8'
135133
};

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"dev": "nodemon app.js",
99
"lint": "prettier src/**/*.js",
1010
"lint:fix": "prettier --write src/**/*.js",
11-
"standard-lint": "standard",
12-
"standard-lint:fix": "standard --fix",
1311
"init-es": "node src/init-es.js",
1412
"init-db": "node src/init-db.js",
1513
"sync-es": "node src/scripts/sync-es.js",
@@ -39,14 +37,13 @@
3937
"mocha-prepare": "^0.1.0",
4038
"nodemon": "^2.0.20",
4139
"nyc": "^14.0.0",
42-
"prettier": "^2.8.1",
43-
"standard": "^17.1.0"
40+
"prettier": "^2.8.1"
4441
},
4542
"dependencies": {
4643
"@grpc/grpc-js": "^1.8.12",
4744
"@opensearch-project/opensearch": "^2.2.0",
48-
"@topcoder-framework/domain-acl": "^0.24.0",
4945
"@topcoder-framework/domain-challenge": "^0.24.1",
46+
"@topcoder-framework/domain-acl": "^0.24.0",
5047
"@topcoder-framework/lib-common": "^0.24.1",
5148
"aws-sdk": "^2.1145.0",
5249
"axios": "^0.19.0",

src/common/challenge-helper.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,7 @@ class ChallengeHelper {
169169

170170
async validateCreateChallengeRequest(currentUser, challenge) {
171171
// projectId is required for non self-service challenges
172-
if (
173-
challenge.legacy.selfService == null &&
174-
challenge.projectId == null &&
175-
this.isProjectIdRequired(challenge.timelineTemplateId)
176-
) {
172+
if (challenge.legacy.selfService == null && challenge.projectId == null) {
177173
throw new errors.BadRequestError("projectId is required for non self-service challenges.");
178174
}
179175

@@ -528,12 +524,6 @@ class ChallengeHelper {
528524
delete overview.totalPrizesInCents;
529525
}
530526
}
531-
532-
isProjectIdRequired(timelineTemplateId) {
533-
const template = _.get(config, "SKIP_PROJECT_ID_BY_TIMLINE_TEMPLATE_ID", '517e76b0-8824-4e72-9b48-a1ebde1793a8');
534-
535-
return template !== timelineTemplateId;
536-
}
537527
}
538528

539529
module.exports = new ChallengeHelper();

src/services/ChallengeService.js

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ async function createChallenge(currentUser, challenge, userToken) {
941941
console.log("TYPE", prizeTypeTmp);
942942
if (challenge.legacy.selfService) {
943943
// if self-service, create a new project (what about if projectId is provided in the payload? confirm with business!)
944-
if (!challenge.projectId && challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)) {
944+
if (!challenge.projectId) {
945945
const selfServiceProjectName = `Self service - ${currentUser.handle} - ${challenge.name}`;
946946
challenge.projectId = await helper.createSelfServiceProject(
947947
selfServiceProjectName,
@@ -963,18 +963,14 @@ async function createChallenge(currentUser, challenge, userToken) {
963963
}
964964

965965
/** Ensure project exists, and set direct project id, billing account id & markup */
966-
if (challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)) {
967-
const { projectId } = challenge;
966+
const { projectId } = challenge;
968967

969-
const { directProjectId } = await projectHelper.getProject(projectId, currentUser);
970-
const { billingAccountId, markup } = await projectHelper.getProjectBillingInformation(
971-
projectId
972-
);
968+
const { directProjectId } = await projectHelper.getProject(projectId, currentUser);
969+
const { billingAccountId, markup } = await projectHelper.getProjectBillingInformation(projectId);
973970

974-
_.set(challenge, "legacy.directProjectId", directProjectId);
975-
_.set(challenge, "billing.billingAccountId", billingAccountId);
976-
_.set(challenge, "billing.markup", markup || 0);
977-
}
971+
_.set(challenge, "legacy.directProjectId", directProjectId);
972+
_.set(challenge, "billing.billingAccountId", billingAccountId);
973+
_.set(challenge, "billing.markup", markup || 0);
978974

979975
if (!_.isUndefined(_.get(challenge, "legacy.reviewType"))) {
980976
_.set(challenge, "legacy.reviewType", _.toUpper(_.get(challenge, "legacy.reviewType")));
@@ -1520,22 +1516,19 @@ async function updateChallenge(currentUser, challengeId, data) {
15201516
convertPrizeSetValuesToDollars(challenge.prizeSets, challenge.overview);
15211517
}
15221518

1523-
let projectId, billingAccountId, markup;
1524-
if (challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)) {
1525-
projectId = _.get(challenge, "projectId");
1519+
const projectId = _.get(challenge, "projectId");
15261520

1527-
({ billingAccountId, markup } = await projectHelper.getProjectBillingInformation(projectId));
1521+
const { billingAccountId, markup } = await projectHelper.getProjectBillingInformation(projectId);
15281522

1529-
if (billingAccountId && _.isUndefined(_.get(challenge, "billing.billingAccountId"))) {
1530-
_.set(data, "billing.billingAccountId", billingAccountId);
1531-
_.set(data, "billing.markup", markup || 0);
1532-
}
1523+
if (billingAccountId && _.isUndefined(_.get(challenge, "billing.billingAccountId"))) {
1524+
_.set(data, "billing.billingAccountId", billingAccountId);
1525+
_.set(data, "billing.markup", markup || 0);
1526+
}
15331527

1534-
// Make sure the user cannot change the direct project ID
1535-
if (data.legacy) {
1536-
data.legacy = _.assign({}, challenge.legacy, data.legacy);
1537-
_.set(data, "legacy.directProjectId", challenge.legacy.directProjectId);
1538-
}
1528+
// Make sure the user cannot change the direct project ID
1529+
if (data.legacy) {
1530+
data.legacy = _.assign({}, challenge.legacy, data.legacy);
1531+
_.set(data, "legacy.directProjectId", challenge.legacy.directProjectId);
15391532
}
15401533

15411534
// Remove fields from data that are not allowed to be updated and that match the existing challenge
@@ -1578,8 +1571,7 @@ async function updateChallenge(currentUser, challengeId, data) {
15781571
if (
15791572
(data.status === constants.challengeStatuses.Approved ||
15801573
data.status === constants.challengeStatuses.Active) &&
1581-
challenge.status !== constants.challengeStatuses.Active &&
1582-
challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)
1574+
challenge.status !== constants.challengeStatuses.Active
15831575
) {
15841576
try {
15851577
const selfServiceProjectName = `Self service - ${challenge.createdBy} - ${challenge.name}`;
@@ -1615,10 +1607,7 @@ async function updateChallenge(currentUser, challengeId, data) {
16151607
}
16161608
}
16171609

1618-
if (
1619-
data.status === constants.challengeStatuses.Draft &&
1620-
challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)
1621-
) {
1610+
if (data.status === constants.challengeStatuses.Draft) {
16221611
try {
16231612
await helper.updateSelfServiceProjectInfo(
16241613
projectId,
@@ -1631,9 +1620,8 @@ async function updateChallenge(currentUser, challengeId, data) {
16311620
}
16321621

16331622
if (
1634-
(data.status === constants.challengeStatuses.CancelledRequirementsInfeasible ||
1635-
data.status === constants.challengeStatuses.CancelledPaymentFailed) &&
1636-
challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)
1623+
data.status === constants.challengeStatuses.CancelledRequirementsInfeasible ||
1624+
data.status === constants.challengeStatuses.CancelledPaymentFailed
16371625
) {
16381626
try {
16391627
await helper.cancelProject(challenge.projectId, data.cancelReason, currentUser);
@@ -1653,8 +1641,7 @@ async function updateChallenge(currentUser, challengeId, data) {
16531641
// if activating a challenge, the challenge must have a billing account id
16541642
if (
16551643
(!billingAccountId || billingAccountId === null) &&
1656-
challenge.status === constants.challengeStatuses.Draft &&
1657-
challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)
1644+
challenge.status === constants.challengeStatuses.Draft
16581645
) {
16591646
throw new errors.BadRequestError(
16601647
"Cannot Activate this project, it has no active billing account."

0 commit comments

Comments
 (0)