@@ -1493,23 +1493,8 @@ async function validateWinners(winners, challengeId) {
1493
1493
async function updateChallenge ( currentUser , challengeId , data ) {
1494
1494
const challenge = await challengeDomain . lookup ( getLookupCriteria ( "id" , challengeId ) ) ;
1495
1495
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
-
1506
1496
const projectId = _ . get ( challenge , "projectId" ) ;
1507
1497
1508
- let sendActivationEmail = false ;
1509
- let sendSubmittedEmail = false ;
1510
- let sendCompletedEmail = false ;
1511
- let sendRejectedEmail = false ;
1512
-
1513
1498
const { billingAccountId, markup } = await projectHelper . getProjectBillingInformation ( projectId ) ;
1514
1499
1515
1500
if ( billingAccountId && _ . isUndefined ( _ . get ( challenge , "billing.billingAccountId" ) ) ) {
@@ -1518,10 +1503,22 @@ async function updateChallenge(currentUser, challengeId, data) {
1518
1503
}
1519
1504
1520
1505
// 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 ) ;
1523
1509
}
1524
1510
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
+
1525
1522
/* BEGIN self-service stuffs */
1526
1523
1527
1524
// TODO: At some point in the future this should be moved to a Self-Service Challenge Helper
@@ -1988,7 +1985,7 @@ updateChallenge.schema = {
1988
1985
. valid ( _ . values ( constants . reviewTypes ) )
1989
1986
. insensitive ( )
1990
1987
. 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 ) ,
1992
1989
directProjectId : Joi . number ( ) ,
1993
1990
forumId : Joi . number ( ) . integer ( ) ,
1994
1991
isTask : Joi . boolean ( ) ,
0 commit comments