Skip to content

Commit

Permalink
Merge pull request #92 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
[Ready Release] Issue Reviewer Role
  • Loading branch information
LieutenantRoger authored Mar 23, 2022
2 parents 81c9f2d + 05079f8 commit cf2b583
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ workflows:
branches:
only:
- develop
- dev-circleci

# Production builds are exectuted only on tagged commits to the testing
# master branch.
Expand Down
3 changes: 3 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/"]',

SUBMITTER_RESOURCE_ROLE_ID: process.env.SUBMITTER_RESOURCE_ROLE_ID || '732339e7-8e30-49d7-9198-cccf9451e221',
REVIEWER_RESOURCE_ROLE_ID: process.env.REVIEWER_RESOURCE_ROLE_ID || '318b9c07-079a-42d9-a81f-b96be1dc1099',
ITERATIVE_REVIEWER_RESOURCE_ROLE_ID: process.env.ITERATIVE_REVIEWER_RESOURCE_ROLE_ID || 'f6df7212-b9d6-4193-bfb1-b383586fce63',

AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://m2m.topcoder-dev.com/',
Expand All @@ -27,6 +29,7 @@ module.exports = {
USER_API_URL: process.env.USER_API_URL || 'https://api.topcoder-dev.com/v3/users',
CHALLENGE_API_URL: process.env.CHALLENGE_API_URL || 'http://localhost:4000/v5/challenges',
CHALLENGE_PHASES_API_URL: process.env.CHALLENGE_PHASES_API_URL || 'https://api.topcoder-dev.com/v5/challenge-phases',
SUBMISSIONS_API_URL: process.env.SUBMISSIONS_API_URL || 'https://api.topcoder-dev.com/v5/submissions',

DYNAMODB: {
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
Expand Down
9 changes: 9 additions & 0 deletions src/services/ResourceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ async function init (currentUser, challengeId, resource, isCreated) {
const handle = resource.memberHandle
const memberId = await helper.getMemberIdByHandle(resource.memberHandle)

// check if the resource is reviewer role and has already made a submission in the challenge
if (resource.roleId === config.REVIEWER_RESOURCE_ROLE_ID || resource.roleId === config.ITERATIVE_REVIEWER_RESOURCE_ROLE_ID) {
const submissionsRes = await helper.getRequest(`${config.SUBMISSIONS_API_URL}`, { challengeId: challengeId, perPage: 100, memberId: memberId })
const submissions = submissionsRes.body
if (submissions.length !== 0) {
throw new errors.ConflictError(`The member has already submitted to the challenge and cannot have a Reviewer or Iterative Reviewer role`)
}
}

// ensure resource role existed
const resourceRole = await getResourceRole(resource.roleId, isCreated)

Expand Down

0 comments on commit cf2b583

Please sign in to comment.