Skip to content

Commit d4b6058

Browse files
authored
Merge pull request #608 from topcoder-platform/feat/constraint-sync
fix: missing legacy properties
2 parents aacf589 + 8e4ed29 commit d4b6058

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/services/ChallengeService.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,23 +1493,8 @@ async function validateWinners(winners, challengeId) {
14931493
async function updateChallenge(currentUser, challengeId, data) {
14941494
const challenge = await challengeDomain.lookup(getLookupCriteria("id", challengeId));
14951495

1496-
// Remove fields from data that are not allowed to be updated and that match the existing challenge
1497-
data = sanitizeData(sanitizeChallenge(data), challenge);
1498-
console.debug("Sanitized Data:", data);
1499-
1500-
if (data.phases != null && data.startDate == null) {
1501-
data.startDate = challenge.startDate;
1502-
}
1503-
1504-
validateChallengeUpdateRequest(currentUser, challenge, data);
1505-
15061496
const projectId = _.get(challenge, "projectId");
15071497

1508-
let sendActivationEmail = false;
1509-
let sendSubmittedEmail = false;
1510-
let sendCompletedEmail = false;
1511-
let sendRejectedEmail = false;
1512-
15131498
const { billingAccountId, markup } = await projectHelper.getProjectBillingInformation(projectId);
15141499

15151500
if (billingAccountId && _.isUndefined(_.get(challenge, "billing.billingAccountId"))) {
@@ -1518,10 +1503,22 @@ async function updateChallenge(currentUser, challengeId, data) {
15181503
}
15191504

15201505
// Make sure the user cannot change the direct project ID
1521-
if (data.legacy && data.legacy.directProjectId) {
1522-
_.unset(data, "legacy.directProjectId");
1506+
if (data.legacy) {
1507+
data.legacy = _.assign({},challenge.legacy, data.legacy)
1508+
_.set(data, "legacy.directProjectId", challenge.legacy.directProjectId);
15231509
}
15241510

1511+
// Remove fields from data that are not allowed to be updated and that match the existing challenge
1512+
data = sanitizeData(sanitizeChallenge(data), challenge);
1513+
console.debug("Sanitized Data:", data);
1514+
1515+
validateChallengeUpdateRequest(currentUser, challenge, data);
1516+
1517+
let sendActivationEmail = false;
1518+
let sendSubmittedEmail = false;
1519+
let sendCompletedEmail = false;
1520+
let sendRejectedEmail = false;
1521+
15251522
/* BEGIN self-service stuffs */
15261523

15271524
// TODO: At some point in the future this should be moved to a Self-Service Challenge Helper
@@ -1988,7 +1985,7 @@ updateChallenge.schema = {
19881985
.valid(_.values(constants.reviewTypes))
19891986
.insensitive()
19901987
.default(constants.reviewTypes.Internal),
1991-
confidentialityType: Joi.string().default(config.DEFAULT_CONFIDENTIALITY_TYPE),
1988+
confidentialityType: Joi.string().allow(null,'').empty(null,'').default(config.DEFAULT_CONFIDENTIALITY_TYPE),
19921989
directProjectId: Joi.number(),
19931990
forumId: Joi.number().integer(),
19941991
isTask: Joi.boolean(),

0 commit comments

Comments
 (0)