diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /routers/api/v1/org | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip |
Move user related model into models/user (#17781)
* Move user related model into models/user
* Fix lint for windows
* Fix windows lint
* Fix windows lint
* Move some tests in models
* Merge
Diffstat (limited to 'routers/api/v1/org')
-rw-r--r-- | routers/api/v1/org/org.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 952e29fba9..84065363f0 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/convert" api "code.gitea.io/gitea/modules/structs" @@ -19,7 +20,7 @@ import ( "code.gitea.io/gitea/services/org" ) -func listUserOrgs(ctx *context.APIContext, u *models.User) { +func listUserOrgs(ctx *context.APIContext, u *user_model.User) { listOptions := utils.GetListOptions(ctx) showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == u.ID) @@ -130,12 +131,12 @@ func GetUserOrgsPermissions(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - var u *models.User + var u *user_model.User if u = user.GetUserByParams(ctx); u == nil { return } - var o *models.User + var o *user_model.User if o = user.GetUserByParamsName(ctx, ":org"); o == nil { return } @@ -206,11 +207,11 @@ func GetAll(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) - publicOrgs, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ + publicOrgs, maxResults, err := user_model.SearchUsers(&user_model.SearchUserOptions{ Actor: ctx.User, ListOptions: listOptions, - Type: models.UserTypeOrganization, - OrderBy: models.SearchOrderByAlphabetically, + Type: user_model.UserTypeOrganization, + OrderBy: db.SearchOrderByAlphabetically, Visible: vMode, }) if err != nil { @@ -266,15 +267,15 @@ func Create(ctx *context.APIContext) { Website: form.Website, Location: form.Location, IsActive: true, - Type: models.UserTypeOrganization, + Type: user_model.UserTypeOrganization, Visibility: visibility, RepoAdminChangeTeamAccess: form.RepoAdminChangeTeamAccess, } if err := models.CreateOrganization(org, ctx.User); err != nil { - if models.IsErrUserAlreadyExist(err) || - models.IsErrNameReserved(err) || - models.IsErrNameCharsNotAllowed(err) || - models.IsErrNamePatternNotAllowed(err) { + if user_model.IsErrUserAlreadyExist(err) || + db.IsErrNameReserved(err) || + db.IsErrNameCharsNotAllowed(err) || + db.IsErrNamePatternNotAllowed(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) } else { ctx.Error(http.StatusInternalServerError, "CreateOrganization", err) @@ -344,7 +345,7 @@ func Edit(ctx *context.APIContext) { if form.RepoAdminChangeTeamAccess != nil { org.RepoAdminChangeTeamAccess = *form.RepoAdminChangeTeamAccess } - if err := models.UpdateUserCols(db.DefaultContext, org.AsUser(), + if err := user_model.UpdateUserCols(db.DefaultContext, org.AsUser(), "full_name", "description", "website", "location", "visibility", "repo_admin_change_team_access", ); err != nil { |