Skip to content

Commit 45b5f3f

Browse files
Set default status to New
1 parent bbdece6 commit 45b5f3f

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
@@ -833,6 +833,12 @@ async function createChallenge (currentUser, challenge) {
833833
}
834834
challenge.name = xss(challenge.name)
835835
challenge.description = xss(challenge.description)
836+
if (!challenge.status) {
837+
challenge.status = constants.challengeStatuses.New
838+
}
839+
if (!challenge.startDate) {
840+
challenge.startDate = new Date()
841+
}
836842
if (challenge.status === constants.challengeStatuses.Active) {
837843
throw new errors.BadRequestError('You cannot create an Active challenge. Please create a Draft challenge and then change the status to Active.')
838844
}
@@ -1042,7 +1048,7 @@ createChallenge.schema = {
10421048
projectId: Joi.number().integer().positive().required(),
10431049
legacyId: Joi.number().integer().positive(),
10441050
startDate: Joi.date(),
1045-
status: Joi.string().valid(_.values(constants.challengeStatuses)).required(),
1051+
status: Joi.string().valid(_.values(constants.challengeStatuses)),
10461052
groups: Joi.array().items(Joi.optionalId()).unique(),
10471053
// gitRepoURLs: Joi.array().items(Joi.string().uri()),
10481054
terms: Joi.array().items(Joi.object().keys({

0 commit comments

Comments
 (0)