From cbd45471b1100bffcd2f18719b56a5da5468756b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 11 May 2022 18:09:36 +0800 Subject: Move access and repo permission to models/perm/access (#19350) * Move access and repo permission to models/perm/access * Remove unnecessary code --- modules/convert/convert.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules/convert/convert.go') diff --git a/modules/convert/convert.go b/modules/convert/convert.go index 3a12ed8f1f..74ede47cef 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/perm" + access_model "code.gitea.io/gitea/models/perm/access" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" @@ -44,16 +45,16 @@ func ToBranch(repo *repo_model.Repository, b *git.Branch, c *git.Commit, bp *mod var canPush bool var err error if user != nil { - hasPerm, err = models.HasAccessUnit(user, repo, unit.TypeCode, perm.AccessModeWrite) + hasPerm, err = access_model.HasAccessUnit(db.DefaultContext, user, repo, unit.TypeCode, perm.AccessModeWrite) if err != nil { return nil, err } - perms, err := models.GetUserRepoPermission(db.DefaultContext, repo, user) + perms, err := access_model.GetUserRepoPermission(db.DefaultContext, repo, user) if err != nil { return nil, err } - canPush = perms.CanWriteToBranch(user, b.Name) + canPush = models.CanMaintainerWriteToBranch(perms, b.Name, user) } return &api.Branch{ @@ -82,7 +83,7 @@ func ToBranch(repo *repo_model.Repository, b *git.Branch, c *git.Commit, bp *mod } if user != nil { - permission, err := models.GetUserRepoPermission(db.DefaultContext, repo, user) + permission, err := access_model.GetUserRepoPermission(db.DefaultContext, repo, user) if err != nil { return nil, err } -- cgit v1.2.3