Skip to content

Commit 8133008

Browse files
authored
Merge pull request #407 from topcoder-platform/issues/fix-385
Set default status to New
2 parents 65e46a8 + 45b5f3f commit 8133008

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/services/ChallengeService.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,12 @@ async function createChallenge (currentUser, challenge) {
846846
}
847847
challenge.name = xss(challenge.name)
848848
challenge.description = xss(challenge.description)
849+
if (!challenge.status) {
850+
challenge.status = constants.challengeStatuses.New
851+
}
852+
if (!challenge.startDate) {
853+
challenge.startDate = new Date()
854+
}
849855
if (challenge.status === constants.challengeStatuses.Active) {
850856
throw new errors.BadRequestError('You cannot create an Active challenge. Please create a Draft challenge and then change the status to Active.')
851857
}
@@ -1055,7 +1061,7 @@ createChallenge.schema = {
10551061
projectId: Joi.number().integer().positive().required(),
10561062
legacyId: Joi.number().integer().positive(),
10571063
startDate: Joi.date(),
1058-
status: Joi.string().valid(_.values(constants.challengeStatuses)).required(),
1064+
status: Joi.string().valid(_.values(constants.challengeStatuses)),
10591065
groups: Joi.array().items(Joi.optionalId()).unique(),
10601066
// gitRepoURLs: Joi.array().items(Joi.string().uri()),
10611067
terms: Joi.array().items(Joi.object().keys({

0 commit comments

Comments
 (0)