diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/org.go | 2 | ||||
-rw-r--r-- | modules/middleware/context.go | 2 | ||||
-rw-r--r-- | modules/middleware/org.go | 26 |
3 files changed, 25 insertions, 5 deletions
diff --git a/modules/auth/org.go b/modules/auth/org.go index 9598e6f834..6183e8c826 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -49,7 +49,7 @@ func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs *binding.Erro // \/ \/ \/ type CreateTeamForm struct { - TeamName string `form:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` + TeamName string `form:"team_name" binding:"Required;AlphaDashDot;MaxSize(30)"` Description string `form:"desc" binding:"MaxSize(255)"` Permission string `form:"permission"` } diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 6ce0f6e1f7..80975e999e 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -71,6 +71,8 @@ type Context struct { IsAdminTeam bool // In owner team or team that has admin permission level. Organization *models.User OrgLink string + + Team *models.Team } } 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 + } } } |