Skip to content

read BA from v5 #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2021
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ The following parameters can be set in config files or in env variables:
- ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately)
- FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes
- RESOURCES_API_URL: TC resources API base URL
- V3_PROJECTS_API_URL: TC direct projects API base URL
- GROUPS_API_URL: TC groups API base URL
- PROJECTS_API_URL: TC projects API base URL
- TERMS_API_URL: TC Terms API Base URL
Expand Down
1 change: 0 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ module.exports = {
GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups',
PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v5/projects',
TERMS_API_URL: process.env.TERMS_API_URL || 'http://localhost:4000/v5/terms',
V3_PROJECTS_API_URL: process.env.V3_PROJECTS_API_URL || 'http://localhost:4000/v3/direct/projects',
// copilot resource role ids allowed to upload attachment
COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS
? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'],
Expand Down
4 changes: 2 additions & 2 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,10 @@ async function getProjectDefaultTerms (projectId) {
*/
async function getProjectBillingAccount (projectId) {
const token = await getM2MToken()
const projectUrl = `${config.V3_PROJECTS_API_URL}/${projectId}`
const projectUrl = `${config.PROJECTS_API_URL}/${projectId}`
try {
const res = await axios.get(projectUrl, { headers: { Authorization: `Bearer ${token}` } })
return _.get(res, 'data.result.content.billingAccountIds[0]', null)
return _.get(res, 'data.billingAccountId', null)
} catch (err) {
if (_.get(err, 'response.status') === HttpStatus.NOT_FOUND) {
throw new errors.BadRequestError(`Project with id: ${projectId} doesn't exist`)
Expand Down
4 changes: 2 additions & 2 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ async function update (currentUser, challengeId, data, isFull) {
if (!_.get(challenge, 'legacy.pureV5Task') && _.isUndefined(_.get(challenge, 'legacy.directProjectId'))) {
throw new errors.BadRequestError('You cannot activate the challenge as it has not been created on legacy yet. Please try again later or contact support.')
}
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId'))
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId'))
// if activating a challenge, the challenge must have a billing account id
if ((!billingAccountId || billingAccountId === null) &&
challenge.status === constants.challengeStatuses.Draft) {
Expand All @@ -1220,7 +1220,7 @@ async function update (currentUser, challengeId, data, isFull) {
if (challenge.status !== constants.challengeStatuses.Active) {
throw new errors.BadRequestError('You cannot mark a Draft challenge as Completed')
}
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId'))
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId'))
}
}

Expand Down