Change constants to UPPERCASE_WITH_UNDERSCORE style
This commit is contained in:
parent
4e79adf6b5
commit
0d158e569b
9 changed files with 42 additions and 42 deletions
|
@ -255,7 +255,7 @@ func ListMyRepos(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{false, access >= models.WriteAccess, true})
|
||||
repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{false, access >= models.ACCESS_MODE_WRITE, true})
|
||||
|
||||
// FIXME: cache result to reduce DB query?
|
||||
if repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(ctx.User.Id) {
|
||||
|
|
|
@ -171,11 +171,11 @@ func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
|||
var auth models.AccessMode
|
||||
switch form.Permission {
|
||||
case "read":
|
||||
auth = models.ReadAccess
|
||||
auth = models.ACCESS_MODE_READ
|
||||
case "write":
|
||||
auth = models.WriteAccess
|
||||
auth = models.ACCESS_MODE_WRITE
|
||||
case "admin":
|
||||
auth = models.AdminAccess
|
||||
auth = models.ACCESS_MODE_ADMIN
|
||||
default:
|
||||
ctx.Error(401)
|
||||
return
|
||||
|
@ -252,11 +252,11 @@ func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
|||
var auth models.AccessMode
|
||||
switch form.Permission {
|
||||
case "read":
|
||||
auth = models.ReadAccess
|
||||
auth = models.ACCESS_MODE_READ
|
||||
case "write":
|
||||
auth = models.WriteAccess
|
||||
auth = models.ACCESS_MODE_WRITE
|
||||
case "admin":
|
||||
auth = models.AdminAccess
|
||||
auth = models.ACCESS_MODE_ADMIN
|
||||
default:
|
||||
ctx.Error(401)
|
||||
return
|
||||
|
|
|
@ -115,9 +115,9 @@ func Http(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
if !isPublicPull {
|
||||
var tp = models.WriteAccess
|
||||
var tp = models.ACCESS_MODE_WRITE
|
||||
if isPull {
|
||||
tp = models.ReadAccess
|
||||
tp = models.ACCESS_MODE_READ
|
||||
}
|
||||
|
||||
has, err := models.HasAccess(authUser, repo, tp)
|
||||
|
@ -125,8 +125,8 @@ func Http(ctx *middleware.Context) {
|
|||
ctx.Handle(401, "no basic auth and digit auth", nil)
|
||||
return
|
||||
} else if !has {
|
||||
if tp == models.ReadAccess {
|
||||
has, err = models.HasAccess(authUser, repo, models.WriteAccess)
|
||||
if tp == models.ACCESS_MODE_READ {
|
||||
has, err = models.HasAccess(authUser, repo, models.ACCESS_MODE_WRITE)
|
||||
if err != nil || !has {
|
||||
ctx.Handle(401, "no basic auth and digit auth", nil)
|
||||
return
|
||||
|
@ -268,7 +268,7 @@ func serviceRpc(rpc string, hr handler) {
|
|||
|
||||
access := hasAccess(r, hr.Config, dir, rpc, true)
|
||||
if access == false {
|
||||
renderNoAccess(w)
|
||||
renderACCESS_MODE_NONE(w)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -495,7 +495,7 @@ func renderNotFound(w http.ResponseWriter) {
|
|||
w.Write([]byte("Not Found"))
|
||||
}
|
||||
|
||||
func renderNoAccess(w http.ResponseWriter) {
|
||||
func renderACCESS_MODE_NONE(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
w.Write([]byte("Forbidden"))
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||
feeds := make([]*models.Action, 0, len(actions))
|
||||
for _, act := range actions {
|
||||
if act.IsPrivate {
|
||||
if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ReadAccess); !has {
|
||||
if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ACCESS_MODE_READ); !has {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ func Profile(ctx *middleware.Context) {
|
|||
continue
|
||||
}
|
||||
if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true},
|
||||
models.ReadAccess); !has {
|
||||
models.ACCESS_MODE_READ); !has {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue