Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const UserRoles = {
}

const ChallengeStatuses = {
Completed: 'Completed'
Completed: 'Completed',
Active: 'Active',
}

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions src/services/ResourceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ async function init (currentUser, challengeId, resource, isCreated) {
throw new errors.BadRequestError('Cannot delete resources of a completed challenge!')
}

if (_.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
throw new errors.BadRequestError(`Cannot create submitter resource on challenge with status ${_.get(challenge, 'status')}`)
}

// Prevent from creating more than 1 submitter resources on tasks
if (_.get(challenge, 'task.isTask', false) && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
const existing = await getResources(currentUser, challengeId, config.SUBMITTER_RESOURCE_ROLE_ID, null, null, 1, 1)
Expand Down