aboutsummaryrefslogtreecommitdiffstats
path: root/modules/middleware
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-08-15 18:29:41 +0800
committerUnknwon <joe2010xtmf@163.com>2014-08-15 18:29:41 +0800
commit36b4c57ff13198196134b853f624fb633061734d (patch)
treee973d2aad41823e50c951a08ec8742030141d675 /modules/middleware
parent3e32b14ad4da2db1b05eeec73936dbbe79cecc45 (diff)
downloadgitea-36b4c57ff13198196134b853f624fb633061734d.tar.gz
gitea-36b4c57ff13198196134b853f624fb633061734d.zip
Finish new organization members and invitation page
Diffstat (limited to 'modules/middleware')
-rw-r--r--modules/middleware/context.go3
-rw-r--r--modules/middleware/org.go23
-rw-r--r--modules/middleware/repo.go2
3 files changed, 22 insertions, 6 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index aa1266d649..6ce0f6e1f7 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -68,7 +68,9 @@ type Context struct {
Org struct {
IsOwner bool
IsMember bool
+ IsAdminTeam bool // In owner team or team that has admin permission level.
Organization *models.User
+ OrgLink string
}
}
@@ -181,7 +183,6 @@ func Contexter() macaron.Handler {
Flash: f,
Session: sess,
}
-
// Compute current URL for real-time change language.
link := ctx.Req.RequestURI
i := strings.Index(link, "?")
diff --git a/modules/middleware/org.go b/modules/middleware/org.go
index 05316a518f..77e999a328 100644
--- a/modules/middleware/org.go
+++ b/modules/middleware/org.go
@@ -13,8 +13,9 @@ import (
func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
return func(ctx *Context) {
var (
- requireMember bool
- requireOwner bool
+ requireMember bool
+ requireOwner bool
+ requireAdminTeam bool
)
if len(args) >= 1 {
requireMember = args[0]
@@ -22,6 +23,9 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
if len(args) >= 2 {
requireOwner = args[1]
}
+ if len(args) >= 3 {
+ requireAdminTeam = args[2]
+ }
orgName := ctx.Params(":org")
@@ -43,13 +47,24 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Org.IsOwner = ctx.Org.Organization.IsOrgOwner(ctx.User.Id)
if ctx.Org.IsOwner {
ctx.Org.IsMember = true
+ ctx.Org.IsAdminTeam = true
} else {
- ctx.Org.IsMember = ctx.Org.Organization.IsOrgMember(ctx.User.Id)
+ if ctx.Org.Organization.IsOrgMember(ctx.User.Id) {
+ ctx.Org.IsMember = true
+ // TODO: ctx.Org.IsAdminTeam
+ }
}
}
- if (requireMember && !ctx.Org.IsMember) || (requireOwner && !ctx.Org.IsOwner) {
+ if (requireMember && !ctx.Org.IsMember) ||
+ (requireOwner && !ctx.Org.IsOwner) ||
+ (requireAdminTeam && !ctx.Org.IsAdminTeam) {
ctx.Handle(404, "OrgAssignment", err)
return
}
+ ctx.Data["IsAdminTeam"] = ctx.Org.IsAdminTeam
+ ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
+
+ ctx.Org.OrgLink = "/org/" + ctx.Org.Organization.Name
+ ctx.Data["OrgLink"] = ctx.Org.OrgLink
}
}
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index a028aab802..3db1932af0 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -146,6 +146,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
}
ctx.Repo.GitRepo = gitRepo
ctx.Repo.RepoLink = "/" + u.Name + "/" + repo.Name
+ ctx.Data["RepoLink"] = ctx.Repo.RepoLink
tags, err := ctx.Repo.GitRepo.GetTags()
if err != nil {
@@ -157,7 +158,6 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["Title"] = u.Name + "/" + repo.Name
ctx.Data["Repository"] = repo
ctx.Data["Owner"] = ctx.Repo.Repository.Owner
- ctx.Data["RepoLink"] = ctx.Repo.RepoLink
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner