Implementation endpoint for APIv4: GET /teams/name/{name} (#5473)

* APIv4: GET /teams/name/{name}

Signed-off-by: Saturnino Abril <saturnino.abril@gmail.com>

* reorganized test with SystemAdminClient

Signed-off-by: Saturnino Abril <saturnino.abril@gmail.com>
Этот коммит содержится в:
Saturnino Abril
2017-02-21 01:27:57 +09:00
коммит произвёл enahum
родитель 22118fafc8
Коммит 623560481b
4 изменённых файлов: 63 добавлений и 0 удалений

Просмотреть файл

@@ -21,6 +21,7 @@ func InitTeam() {
BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET")
BaseRoutes.Team.Handle("/stats", ApiHandler(getTeamStats)).Methods("GET")
BaseRoutes.TeamByName.Handle("", ApiSessionRequired(getTeamByName)).Methods("GET")
BaseRoutes.TeamMember.Handle("", ApiSessionRequired(getTeamMember)).Methods("GET")
}
@@ -66,6 +67,21 @@ func getTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
func getTeamByName(c *Context, w http.ResponseWriter, r *http.Request) {
if team, err := app.GetTeamByName(c.Params.TeamName); err != nil {
c.Err = err
return
} else {
if team.Type != model.TEAM_OPEN && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
return
}
w.Write([]byte(team.ToJson()))
return
}
}
func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireUserId()
if c.Err != nil {