aboutsummaryrefslogtreecommitdiffstats
path: root/modules/convert
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 /modules/convert
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 'modules/convert')
-rw-r--r--modules/convert/convert.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/convert/convert.go b/modules/convert/convert.go
index 41a044c6d7..43300f603e 100644
--- a/modules/convert/convert.go
+++ b/modules/convert/convert.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/models"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/auth"
+ "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"
@@ -98,15 +99,15 @@ func ToBranchProtection(bp *models.ProtectedBranch) *api.BranchProtection {
if err != nil {
log.Error("GetUserNamesByIDs (ApprovalsWhitelistUserIDs): %v", err)
}
- pushWhitelistTeams, err := models.GetTeamNamesByID(bp.WhitelistTeamIDs)
+ pushWhitelistTeams, err := organization.GetTeamNamesByID(bp.WhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (WhitelistTeamIDs): %v", err)
}
- mergeWhitelistTeams, err := models.GetTeamNamesByID(bp.MergeWhitelistTeamIDs)
+ mergeWhitelistTeams, err := organization.GetTeamNamesByID(bp.MergeWhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (MergeWhitelistTeamIDs): %v", err)
}
- approvalsWhitelistTeams, err := models.GetTeamNamesByID(bp.ApprovalsWhitelistTeamIDs)
+ approvalsWhitelistTeams, err := organization.GetTeamNamesByID(bp.ApprovalsWhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (ApprovalsWhitelistTeamIDs): %v", err)
}
@@ -280,7 +281,7 @@ func ToDeployKey(apiLink string, key *asymkey_model.DeployKey) *api.DeployKey {
}
// ToOrganization convert user_model.User to api.Organization
-func ToOrganization(org *models.Organization) *api.Organization {
+func ToOrganization(org *organization.Organization) *api.Organization {
return &api.Organization{
ID: org.ID,
AvatarURL: org.AsUser().AvatarLink(),
@@ -294,8 +295,8 @@ func ToOrganization(org *models.Organization) *api.Organization {
}
}
-// ToTeam convert models.Team to api.Team
-func ToTeam(team *models.Team) *api.Team {
+// ToTeam convert organization.Team to api.Team
+func ToTeam(team *organization.Team) *api.Team {
if team == nil {
return nil
}