Skip to content

allow booking manager to access all teams #69

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
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
116 changes: 115 additions & 1 deletion docs/Topcoder-bookings-api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4125,6 +4125,54 @@
},
"response": []
},
{
"name": "GET /taas-teams with booking manager",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token_bookingManager}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/taas-teams?perPage=10&page=1&name=*taas*&sortBy=lastActivityAt&sortOrder=desc",
"host": [
"{{URL}}"
],
"path": [
"taas-teams"
],
"query": [
{
"key": "perPage",
"value": "10"
},
{
"key": "page",
"value": "1"
},
{
"key": "name",
"value": "*taas*",
"description": "case-insensitive; support wildcard match"
},
{
"key": "sortBy",
"value": "lastActivityAt",
"description": "allows: createdAt, updatedAt, lastActivityAt, id, status, name, type, best match"
},
{
"key": "sortOrder",
"value": "desc",
"description": "allows: asc, desc"
}
]
}
},
"response": []
},
{
"name": "GET /taas-teams with m2m read",
"request": {
Expand Down Expand Up @@ -4178,6 +4226,36 @@
},
"response": []
},
{
"name": "GET /taas-teams/:id with booking manager",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token_bookingManager}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/taas-teams/:projectId",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
":projectId"
],
"variable": [
{
"key": "projectId",
"value": "16705"
}
]
}
},
"response": []
},
{
"name": "GET /taas-teams/:id with m2m read",
"request": {
Expand Down Expand Up @@ -4244,6 +4322,42 @@
},
"response": []
},
{
"name": "GET /taas-teams/:id/jobs/:jobId with booking manager",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token_bookingManager}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/taas-teams/:projectId/jobs/:jobId",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
":projectId",
"jobs",
":jobId"
],
"variable": [
{
"key": "projectId",
"value": "16705"
},
{
"key": "jobId",
"value": "948a25a6-086f-4a96-aad5-9ccd2d3e87b2"
}
]
}
},
"response": []
},
{
"name": "GET /taas-teams/:id/jobs/:jobId with m2m read",
"request": {
Expand Down Expand Up @@ -6853,4 +6967,4 @@
}
],
"protocolProfileBehavior": {}
}
}
14 changes: 4 additions & 10 deletions src/services/TeamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function _getJobsByProjectIds (projectIds) {
* @returns {Object} the search result, contain total/page/perPage and result array
*/
async function searchTeams (currentUser, criteria) {
if (currentUser.isMachine) {
if (currentUser.isBookingManager || currentUser.isMachine) {
const m2mToken = await helper.getM2Mtoken()
currentUser.jwtToken = `Bearer ${m2mToken}`
}
Expand Down Expand Up @@ -197,7 +197,7 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
* @returns {Object} the team
*/
async function getTeam (currentUser, id) {
if (currentUser.isMachine) {
if (currentUser.isBookingManager || currentUser.isMachine) {
const m2mToken = await helper.getM2Mtoken()
currentUser.jwtToken = `Bearer ${m2mToken}`
}
Expand Down Expand Up @@ -253,7 +253,7 @@ getTeam.schema = Joi.object().keys({
* @returns the team job
*/
async function getTeamJob (currentUser, id, jobId) {
if (currentUser.isMachine) {
if (currentUser.isBookingManager || currentUser.isMachine) {
const m2mToken = await helper.getM2Mtoken()
currentUser.jwtToken = `Bearer ${m2mToken}`
}
Expand Down Expand Up @@ -286,13 +286,7 @@ async function getTeamJob (currentUser, id, jobId) {
const userHandles = _.map(candidates, 'handle')
if (userHandles && userHandles.length > 0) {
// Get user photo from /v5/members
let members
if (currentUser.isMachine) {
const m2mToken = await helper.getTopcoderM2MToken()
members = await helper.getMembers(`Bearer ${m2mToken}`, userHandles)
} else {
members = await helper.getMembers(currentUser.jwtToken, userHandles)
}
const members = await helper.getMembers(currentUser.jwtToken, userHandles)

for (const item of candidates) {
item.resumeLink = null
Expand Down