diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-03-29 14:29:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 14:29:02 +0800 |
commit | b06b9a056c0af751e576978f6ef3c914ee959b9c (patch) | |
tree | aa0d11413038baa5d47af65fd435665c698fe456 /routers/web/org/members.go | |
parent | d4c789dfc1c341413b77a2f21fe7339982102bed (diff) | |
download | gitea-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 'routers/web/org/members.go')
-rw-r--r-- | routers/web/org/members.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/routers/web/org/members.go b/routers/web/org/members.go index 9e65e61404..add8e724bd 100644 --- a/routers/web/org/members.go +++ b/routers/web/org/members.go @@ -9,6 +9,7 @@ import ( "net/http" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" @@ -31,7 +32,7 @@ func Members(ctx *context.Context) { page = 1 } - opts := &models.FindOrgMembersOpts{ + opts := &organization.FindOrgMembersOpts{ OrgID: org.ID, PublicOnly: true, } @@ -45,7 +46,7 @@ func Members(ctx *context.Context) { opts.PublicOnly = !isMember && !ctx.Doer.IsAdmin } - total, err := models.CountOrgMembers(opts) + total, err := organization.CountOrgMembers(opts) if err != nil { ctx.Error(http.StatusInternalServerError, "CountOrgMembers") return @@ -54,7 +55,7 @@ func Members(ctx *context.Context) { pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5) opts.ListOptions.Page = page opts.ListOptions.PageSize = setting.UI.MembersPagingNum - members, membersIsPublic, err := models.FindOrgMembers(opts) + members, membersIsPublic, err := organization.FindOrgMembers(opts) if err != nil { ctx.ServerError("GetMembers", err) return @@ -84,20 +85,20 @@ func MembersAction(ctx *context.Context) { ctx.Error(http.StatusNotFound) return } - err = models.ChangeOrgUserStatus(org.ID, uid, false) + err = organization.ChangeOrgUserStatus(org.ID, uid, false) case "public": if ctx.Doer.ID != uid && !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) return } - err = models.ChangeOrgUserStatus(org.ID, uid, true) + err = organization.ChangeOrgUserStatus(org.ID, uid, true) case "remove": if !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) return } - err = org.RemoveMember(uid) - if models.IsErrLastOrgOwner(err) { + err = models.RemoveOrgUser(org.ID, uid) + if organization.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.JSON(http.StatusOK, map[string]interface{}{ "redirect": ctx.Org.OrgLink + "/members", @@ -105,8 +106,8 @@ func MembersAction(ctx *context.Context) { return } case "leave": - err = org.RemoveMember(ctx.Doer.ID) - if models.IsErrLastOrgOwner(err) { + err = models.RemoveOrgUser(org.ID, ctx.Doer.ID) + if organization.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.JSON(http.StatusOK, map[string]interface{}{ "redirect": ctx.Org.OrgLink + "/members", |