-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #445 from developmentseed/fix/org-map
Org Map fixes
- Loading branch information
Showing
6 changed files
with
168 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createBaseHandler } from '../../../../middlewares/base-handler' | ||
import { validate } from '../../../../middlewares/validation' | ||
import Team from '../../../../models/team' | ||
import * as Yup from 'yup' | ||
import canViewOrgTeams from '../../../../middlewares/can/view-org-teams' | ||
|
||
const handler = createBaseHandler() | ||
|
||
/** | ||
* @swagger | ||
* /organizations/{id}/teams: | ||
* get: | ||
* summary: Get locations of teams of an organization | ||
* tags: | ||
* - organizations | ||
* parameters: | ||
* - in: path | ||
* name: id | ||
* required: true | ||
* description: Numeric ID of the organization the teams are part of. | ||
* schema: | ||
* type: integer | ||
* responses: | ||
* 200: | ||
* description: A list of teams. | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* data: | ||
* $ref: '#/components/schemas/ArrayOfTeams' | ||
*/ | ||
handler.get( | ||
canViewOrgTeams, | ||
validate({ | ||
query: Yup.object({ | ||
orgId: Yup.number().required().positive().integer(), | ||
}).required(), | ||
}), | ||
async function (req, res) { | ||
const { orgId } = req.query | ||
const { | ||
org: { isMember, isOwner, isManager }, | ||
} = req | ||
const teamList = await Team.list({ | ||
organizationId: orgId, | ||
includePrivate: isMember || isManager || isOwner, | ||
}) | ||
|
||
return res.send({ data: teamList }) | ||
} | ||
) | ||
|
||
export default handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters