From 90e93b1f3a10f2810f7a34024288ae73e64e1098 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 21 Mar 2016 12:53:04 -0400 Subject: Change list teams API to non-admin specific --- routers/api/v1/org/team.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 routers/api/v1/org/team.go (limited to 'routers/api/v1/org/team.go') diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go new file mode 100644 index 0000000000..fad0d2f703 --- /dev/null +++ b/routers/api/v1/org/team.go @@ -0,0 +1,31 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package org + +import ( + api "github.com/gogits/go-gogs-client" + + "github.com/gogits/gogs/modules/context" + "github.com/gogits/gogs/routers/api/v1/convert" + "github.com/gogits/gogs/routers/api/v1/user" +) + +func ListTeams(ctx *context.APIContext) { + org := user.GetUserByParamsName(ctx, ":orgname") + if ctx.Written() { + return + } + + if err := org.GetTeams(); err != nil { + ctx.Error(500, "GetTeams", err) + return + } + + apiTeams := make([]*api.Team, len(org.Teams)) + for i := range org.Teams { + apiTeams[i] = convert.ToTeam(org.Teams[i]) + } + ctx.JSON(200, apiTeams) +} -- cgit v1.2.3