1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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
This commit is contained in:
Lunny Xiao
2021-11-24 17:49:20 +08:00
committed by GitHub
parent 4e7ca946da
commit a666829a37
345 changed files with 4230 additions and 3813 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"code.gitea.io/gitea/models"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/log"
@@ -53,9 +54,9 @@ func Transfer(ctx *context.APIContext) {
opts := web.GetForm(ctx).(*api.TransferRepoOption)
newOwner, err := models.GetUserByName(opts.NewOwner)
newOwner, err := user_model.GetUserByName(opts.NewOwner)
if err != nil {
if models.IsErrUserNotExist(err) {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found")
return
}
@@ -63,7 +64,7 @@ func Transfer(ctx *context.APIContext) {
return
}
if newOwner.Type == models.UserTypeOrganization {
if newOwner.Type == user_model.UserTypeOrganization {
if !ctx.User.IsAdmin && newOwner.Visibility == api.VisibleTypePrivate && !models.OrgFromUser(newOwner).HasMemberWithUserID(ctx.User.ID) {
// The user shouldn't know about this organization
ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found")