diff options
Diffstat (limited to 'routers/api/v1/org/org.go')
-rw-r--r-- | routers/api/v1/org/org.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index fcc98f4b78..d55a4a4514 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -8,8 +8,8 @@ package org import ( "net/http" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/perm" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -25,17 +25,17 @@ func listUserOrgs(ctx *context.APIContext, u *user_model.User) { listOptions := utils.GetListOptions(ctx) showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == u.ID) - opts := models.FindOrgOptions{ + opts := organization.FindOrgOptions{ ListOptions: listOptions, UserID: u.ID, IncludePrivate: showPrivate, } - orgs, err := models.FindOrgs(opts) + orgs, err := organization.FindOrgs(opts) if err != nil { ctx.Error(http.StatusInternalServerError, "FindOrgs", err) return } - maxResults, err := models.CountOrgs(opts) + maxResults, err := organization.CountOrgs(opts) if err != nil { ctx.Error(http.StatusInternalServerError, "CountOrgs", err) return @@ -135,12 +135,12 @@ func GetUserOrgsPermissions(ctx *context.APIContext) { op := api.OrganizationPermissions{} - if !models.HasOrgOrUserVisible(o, ctx.ContextUser) { + if !organization.HasOrgOrUserVisible(ctx, o, ctx.ContextUser) { ctx.NotFound("HasOrgOrUserVisible", nil) return } - org := models.OrgFromUser(o) + org := organization.OrgFromUser(o) authorizeLevel, err := org.GetOrgUserMaxAuthorizeLevel(ctx.ContextUser.ID) if err != nil { ctx.Error(http.StatusInternalServerError, "GetOrgUserAuthorizeLevel", err) @@ -212,7 +212,7 @@ func GetAll(ctx *context.APIContext) { } orgs := make([]*api.Organization, len(publicOrgs)) for i := range publicOrgs { - orgs[i] = convert.ToOrganization(models.OrgFromUser(publicOrgs[i])) + orgs[i] = convert.ToOrganization(organization.OrgFromUser(publicOrgs[i])) } ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) @@ -252,7 +252,7 @@ func Create(ctx *context.APIContext) { visibility = api.VisibilityModes[form.Visibility] } - org := &models.Organization{ + org := &organization.Organization{ Name: form.UserName, FullName: form.FullName, Description: form.Description, @@ -263,7 +263,7 @@ func Create(ctx *context.APIContext) { Visibility: visibility, RepoAdminChangeTeamAccess: form.RepoAdminChangeTeamAccess, } - if err := models.CreateOrganization(org, ctx.Doer); err != nil { + if err := organization.CreateOrganization(org, ctx.Doer); err != nil { if user_model.IsErrUserAlreadyExist(err) || db.IsErrNameReserved(err) || db.IsErrNameCharsNotAllowed(err) || @@ -295,7 +295,7 @@ func Get(ctx *context.APIContext) { // "200": // "$ref": "#/responses/Organization" - if !models.HasOrgOrUserVisible(ctx.Org.Organization.AsUser(), ctx.Doer) { + if !organization.HasOrgOrUserVisible(ctx, ctx.Org.Organization.AsUser(), ctx.Doer) { ctx.NotFound("HasOrgOrUserVisible", nil) return } |