summaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-03-29 14:29:02 +0800
committerGitHub <noreply@github.com>2022-03-29 14:29:02 +0800
commitb06b9a056c0af751e576978f6ef3c914ee959b9c (patch)
treeaa0d11413038baa5d47af65fd435665c698fe456 /models/repo_collaboration.go
parentd4c789dfc1c341413b77a2f21fe7339982102bed (diff)
downloadgitea-b06b9a056c0af751e576978f6ef3c914ee959b9c.tar.gz
gitea-b06b9a056c0af751e576978f6ef3c914ee959b9c.zip
Move organization related structs into sub package (#18518)
* Move organization related structs into sub package * Fix test * Fix lint * Move more functions into sub packages * Fix bug * Fix test * Update models/organization/team_repo.go Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Fix fmt * Follow suggestion from @Gusted * Fix test * Fix test * Fix bug * Use ctx but db.DefaultContext on routers * Fix bug * Fix bug * fix bug * Update models/organization/team_user.go * Fix bug Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go17
1 files changed, 2 insertions, 15 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index 3aca1023e6..d94b61b449 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -10,6 +10,7 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
@@ -259,20 +260,6 @@ func reconsiderWatches(ctx context.Context, repo *repo_model.Repository, uid int
return removeIssueWatchersByRepoID(db.GetEngine(ctx), uid, repo.ID)
}
-func getRepoTeams(e db.Engine, repo *repo_model.Repository) (teams []*Team, err error) {
- return teams, e.
- Join("INNER", "team_repo", "team_repo.team_id = team.id").
- Where("team.org_id = ?", repo.OwnerID).
- And("team_repo.repo_id=?", repo.ID).
- OrderBy("CASE WHEN name LIKE '" + ownerTeamName + "' THEN '' ELSE name END").
- Find(&teams)
-}
-
-// GetRepoTeams gets the list of teams that has access to the repository
-func GetRepoTeams(repo *repo_model.Repository) ([]*Team, error) {
- return getRepoTeams(db.GetEngine(db.DefaultContext), repo)
-}
-
// IsOwnerMemberCollaborator checks if a provided user is the owner, a collaborator or a member of a team in a repository
func IsOwnerMemberCollaborator(repo *repo_model.Repository, userID int64) (bool, error) {
if repo.OwnerID == userID {
@@ -282,7 +269,7 @@ func IsOwnerMemberCollaborator(repo *repo_model.Repository, userID int64) (bool,
Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id").
Where("team_repo.repo_id = ?", repo.ID).
And("team_unit.`type` = ?", unit.TypeCode).
- And("team_user.uid = ?", userID).Table("team_user").Exist(&TeamUser{})
+ And("team_user.uid = ?", userID).Table("team_user").Exist(&organization.TeamUser{})
if err != nil {
return false, err
}