diff options
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", |