1
0
mirror of https://github.com/go-gitea/gitea synced 2024-11-10 17:25:54 +01:00

Refactor .IsAdminTeam to .IsTeamAdmin and requireAdminTeam to requireTeamAdmin

This commit is contained in:
Florian Kaiser 2016-01-31 15:18:28 +00:00
parent e35791b2b2
commit 8c4588c4c9
2 changed files with 8 additions and 8 deletions

@ -66,7 +66,7 @@ type Context struct {
IsOwner bool IsOwner bool
IsMember bool IsMember bool
IsTeamMember bool // Is member of team. IsTeamMember bool // Is member of team.
IsAdminTeam bool // In owner team or team that has admin permission level. IsTeamAdmin bool // In owner team or team that has admin permission level.
Organization *models.User Organization *models.User
OrgLink string OrgLink string

@ -18,7 +18,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
requireMember bool requireMember bool
requireOwner bool requireOwner bool
requireTeamMember bool requireTeamMember bool
requireAdminTeam bool requireTeamAdmin bool
) )
if len(args) >= 1 { if len(args) >= 1 {
requireMember = args[0] requireMember = args[0]
@ -30,7 +30,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
requireTeamMember = args[2] requireTeamMember = args[2]
} }
if len(args) >= 4 { if len(args) >= 4 {
requireAdminTeam = args[3] requireTeamAdmin = args[3]
} }
orgName := ctx.Params(":org") orgName := ctx.Params(":org")
@ -59,13 +59,13 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
ctx.Org.IsOwner = true ctx.Org.IsOwner = true
ctx.Org.IsMember = true ctx.Org.IsMember = true
ctx.Org.IsTeamMember = true ctx.Org.IsTeamMember = true
ctx.Org.IsAdminTeam = true ctx.Org.IsTeamAdmin = true
} else if ctx.IsSigned { } else if ctx.IsSigned {
ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id) ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id)
if ctx.Org.IsOwner { if ctx.Org.IsOwner {
ctx.Org.IsMember = true ctx.Org.IsMember = true
ctx.Org.IsTeamMember = true ctx.Org.IsTeamMember = true
ctx.Org.IsAdminTeam = true ctx.Org.IsTeamAdmin = true
} else { } else {
if org.IsOrgMember(ctx.User.Id) { if org.IsOrgMember(ctx.User.Id) {
ctx.Org.IsMember = true ctx.Org.IsMember = true
@ -118,9 +118,9 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
return return
} }
ctx.Org.IsAdminTeam = ctx.Org.Team.IsOwnerTeam() || ctx.Org.Team.Authorize >= models.ACCESS_MODE_ADMIN ctx.Org.IsTeamAdmin = ctx.Org.Team.IsOwnerTeam() || ctx.Org.Team.Authorize >= models.ACCESS_MODE_ADMIN
ctx.Data["IsAdminTeam"] = ctx.Org.IsAdminTeam ctx.Data["IsTeamAdmin"] = ctx.Org.IsTeamAdmin
if requireAdminTeam && !ctx.Org.IsAdminTeam { if requireTeamAdmin && !ctx.Org.IsTeamAdmin {
ctx.Handle(404, "OrgAssignment", err) ctx.Handle(404, "OrgAssignment", err)
return return
} }