Skip to content

Commit cf2b583

Browse files
Merge pull request #92 from topcoder-platform/develop
[Ready Release] Issue Reviewer Role
2 parents 81c9f2d + 05079f8 commit cf2b583

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.circleci/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ workflows:
122122
branches:
123123
only:
124124
- develop
125-
- dev-circleci
126125

127126
# Production builds are exectuted only on tagged commits to the testing
128127
# master branch.

config/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module.exports = {
1414
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/"]',
1515

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

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

3134
DYNAMODB: {
3235
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,

src/services/ResourceService.js

+9
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ async function init (currentUser, challengeId, resource, isCreated) {
243243
const handle = resource.memberHandle
244244
const memberId = await helper.getMemberIdByHandle(resource.memberHandle)
245245

246+
// check if the resource is reviewer role and has already made a submission in the challenge
247+
if (resource.roleId === config.REVIEWER_RESOURCE_ROLE_ID || resource.roleId === config.ITERATIVE_REVIEWER_RESOURCE_ROLE_ID) {
248+
const submissionsRes = await helper.getRequest(`${config.SUBMISSIONS_API_URL}`, { challengeId: challengeId, perPage: 100, memberId: memberId })
249+
const submissions = submissionsRes.body
250+
if (submissions.length !== 0) {
251+
throw new errors.ConflictError(`The member has already submitted to the challenge and cannot have a Reviewer or Iterative Reviewer role`)
252+
}
253+
}
254+
246255
// ensure resource role existed
247256
const resourceRole = await getResourceRole(resource.roleId, isCreated)
248257

0 commit comments

Comments
 (0)