summaryrefslogtreecommitdiffstats
path: root/modules/middleware/org.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-08-16 16:21:17 +0800
committerUnknwon <joe2010xtmf@163.com>2014-08-16 16:21:17 +0800
commitbba707de36d9bfbdb3001e3e89fac0c072aa14e9 (patch)
tree2b3ee7fc662baea04cecdf14b8a2758c108f83cc /modules/middleware/org.go
parent78add502d71dca43bb59ab9ad91745c64d0bf74d (diff)
downloadgitea-bba707de36d9bfbdb3001e3e89fac0c072aa14e9.tar.gz
gitea-bba707de36d9bfbdb3001e3e89fac0c072aa14e9.zip
Finish team list, create new team, join/leave team page
Diffstat (limited to 'modules/middleware/org.go')
-rw-r--r--modules/middleware/org.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/middleware/org.go b/modules/middleware/org.go
index 77e999a328..c85221a5ab 100644
--- a/modules/middleware/org.go
+++ b/modules/middleware/org.go
@@ -41,15 +41,16 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
}
return
}
- ctx.Data["Org"] = ctx.Org.Organization
+ org := ctx.Org.Organization
+ ctx.Data["Org"] = org
if ctx.IsSigned {
- ctx.Org.IsOwner = ctx.Org.Organization.IsOrgOwner(ctx.User.Id)
+ ctx.Org.IsOwner = org.IsOrgOwner(ctx.User.Id)
if ctx.Org.IsOwner {
ctx.Org.IsMember = true
ctx.Org.IsAdminTeam = true
} else {
- if ctx.Org.Organization.IsOrgMember(ctx.User.Id) {
+ if org.IsOrgMember(ctx.User.Id) {
ctx.Org.IsMember = true
// TODO: ctx.Org.IsAdminTeam
}
@@ -64,7 +65,24 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["IsAdminTeam"] = ctx.Org.IsAdminTeam
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
- ctx.Org.OrgLink = "/org/" + ctx.Org.Organization.Name
+ ctx.Org.OrgLink = "/org/" + org.Name
ctx.Data["OrgLink"] = ctx.Org.OrgLink
+
+ // Team.
+ teamName := ctx.Params(":team")
+ if len(teamName) > 0 {
+ ctx.Org.Team, err = org.GetTeam(teamName)
+ if err != nil {
+ if err == models.ErrTeamNotExist {
+ ctx.Handle(404, "GetTeam", err)
+ } else if redirect {
+ ctx.Redirect("/")
+ } else {
+ ctx.Handle(500, "GetTeam", err)
+ }
+ return
+ }
+ ctx.Data["Team"] = ctx.Org.Team
+ }
}
}