summaryrefslogtreecommitdiffstats
path: root/routers/org
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-06-29 16:30:41 -0400
committerUnknown <joe2010xtmf@163.com>2014-06-29 16:30:41 -0400
commite4ea5cf5984652e3966825bc2b68dd1abc3eef1c (patch)
tree7647c242061c1ab022db880733f0219f0af5bd2c /routers/org
parent99713e1180ad149faf6442bba311fec6e501aa00 (diff)
downloadgitea-e4ea5cf5984652e3966825bc2b68dd1abc3eef1c.tar.gz
gitea-e4ea5cf5984652e3966825bc2b68dd1abc3eef1c.zip
Finish Teams page
Diffstat (limited to 'routers/org')
-rw-r--r--routers/org/members.go16
-rw-r--r--routers/org/org.go9
-rw-r--r--routers/org/teams.go47
3 files changed, 59 insertions, 13 deletions
diff --git a/routers/org/members.go b/routers/org/members.go
new file mode 100644
index 0000000000..c6f49b14bd
--- /dev/null
+++ b/routers/org/members.go
@@ -0,0 +1,16 @@
+// Copyright 2014 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 (
+ "github.com/go-martini/martini"
+
+ "github.com/gogits/gogs/modules/middleware"
+)
+
+func Members(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["Title"] = "Organization " + params["org"] + " Members"
+ ctx.HTML(200, "org/members")
+}
diff --git a/routers/org/org.go b/routers/org/org.go
index ba4adc5b5a..337fe89eb7 100644
--- a/routers/org/org.go
+++ b/routers/org/org.go
@@ -36,7 +36,7 @@ func Home(ctx *middleware.Context, params martini.Params) {
ctx.Data["Org"] = org
ctx.Data["Repos"], err = models.GetRepositories(org.Id,
- ctx.IsSigned && models.IsOrganizationMember(org.Id, ctx.User.Id))
+ ctx.IsSigned && org.IsOrgMember(ctx.User.Id))
if err != nil {
ctx.Handle(500, "org.Home(GetRepositories)", err)
return
@@ -57,11 +57,6 @@ func Home(ctx *middleware.Context, params martini.Params) {
ctx.HTML(200, HOME)
}
-func Members(ctx *middleware.Context, params martini.Params) {
- ctx.Data["Title"] = "Organization " + params["org"] + " Members"
- ctx.HTML(200, "org/members")
-}
-
func New(ctx *middleware.Context) {
ctx.Data["Title"] = "Create An Organization"
ctx.HTML(200, NEW)
@@ -206,7 +201,7 @@ func DeletePost(ctx *middleware.Context, params martini.Params) {
}
ctx.Data["Org"] = org
- if !models.IsOrganizationOwner(org.Id, ctx.User.Id) {
+ if !org.IsOrgOwner(ctx.User.Id) {
ctx.Error(403)
return
}
diff --git a/routers/org/teams.go b/routers/org/teams.go
index 9ca5185a94..eef6a63469 100644
--- a/routers/org/teams.go
+++ b/routers/org/teams.go
@@ -1,21 +1,56 @@
+// Copyright 2014 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 (
"github.com/go-martini/martini"
+
+ "github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
)
+const (
+ TEAMS base.TplName = "org/teams"
+)
+
func Teams(ctx *middleware.Context, params martini.Params) {
- ctx.Data["Title"] = "Organization "+params["org"]+" Teams"
- ctx.HTML(200, "org/teams")
+ ctx.Data["Title"] = "Organization " + params["org"] + " Teams"
+
+ org, err := models.GetUserByName(params["org"])
+ if err != nil {
+ if err == models.ErrUserNotExist {
+ ctx.Handle(404, "org.Teams(GetUserByName)", err)
+ } else {
+ ctx.Handle(500, "org.Teams(GetUserByName)", err)
+ }
+ return
+ }
+ ctx.Data["Org"] = org
+
+ if err = org.GetTeams(); err != nil {
+ ctx.Handle(500, "org.Teams(GetTeams)", err)
+ return
+ }
+ for _, t := range org.Teams {
+ if err = t.GetMembers(); err != nil {
+ ctx.Handle(500, "org.Home(GetMembers)", err)
+ return
+ }
+ }
+ ctx.Data["Teams"] = org.Teams
+
+ ctx.HTML(200, TEAMS)
}
func NewTeam(ctx *middleware.Context, params martini.Params) {
- ctx.Data["Title"] = "Organization "+params["org"]+" New Team"
+ ctx.Data["Title"] = "Organization " + params["org"] + " New Team"
ctx.HTML(200, "org/new_team")
}
-func EditTeam(ctx *middleware.Context, params martini.Params){
- ctx.Data["Title"] = "Organization "+params["org"]+" Edit Team"
- ctx.HTML(200,"org/edit_team")
+func EditTeam(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["Title"] = "Organization " + params["org"] + " Edit Team"
+ ctx.HTML(200, "org/edit_team")
}