From b06b9a056c0af751e576978f6ef3c914ee959b9c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 29 Mar 2022 14:29:02 +0800 Subject: 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 * Apply suggestions from code review Co-authored-by: KN4CK3R * 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 Co-authored-by: wxiaoguang --- modules/context/org.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/context/org.go') diff --git a/modules/context/org.go b/modules/context/org.go index 8e292fa1c5..f8607bd29f 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -8,7 +8,7 @@ package context import ( "strings" - "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/perm" user_model "code.gitea.io/gitea/models/user" ) @@ -19,12 +19,12 @@ type Organization struct { IsMember bool IsTeamMember bool // Is member of team. IsTeamAdmin bool // In owner team or team that has admin permission level. - Organization *models.Organization + Organization *organization.Organization OrgLink string CanCreateOrgRepo bool - Team *models.Team - Teams []*models.Team + Team *organization.Team + Teams []*organization.Team } // HandleOrgAssignment handles organization assignment @@ -51,9 +51,9 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { orgName := ctx.Params(":org") var err error - ctx.Org.Organization, err = models.GetOrgByName(orgName) + ctx.Org.Organization, err = organization.GetOrgByName(orgName) if err != nil { - if models.IsErrOrgNotExist(err) { + if organization.IsErrOrgNotExist(err) { redirectUserID, err := user_model.LookupUserRedirect(orgName) if err == nil { RedirectToUser(ctx, orgName, redirectUserID) @@ -120,7 +120,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember ctx.Data["IsPublicMember"] = func(uid int64) bool { - is, _ := models.IsPublicMembership(ctx.Org.Organization.ID, uid) + is, _ := organization.IsPublicMembership(ctx.Org.Organization.ID, uid) return is } ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo -- cgit v1.2.3