mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Use a standalone struct name for Organization (#17632)
* Use a standalone struct name for Organization * recover unnecessary change * make the code readable * Fix template failure * Fix template failure * Move HasMemberWithUserID to org * Fix test * Remove unnecessary user type check * Fix test Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -31,7 +31,7 @@ func listUserOrgs(ctx *context.APIContext, u *models.User) {
|
||||
}
|
||||
|
||||
maxResults := len(orgs)
|
||||
orgs, _ = util.PaginateSlice(orgs, listOptions.Page, listOptions.PageSize).([]*models.User)
|
||||
orgs, _ = util.PaginateSlice(orgs, listOptions.Page, listOptions.PageSize).([]*models.Organization)
|
||||
|
||||
apiOrgs := make([]*api.Organization, len(orgs))
|
||||
for i := range orgs {
|
||||
@@ -141,7 +141,8 @@ func GetUserOrgsPermissions(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
authorizeLevel, err := o.GetOrgUserMaxAuthorizeLevel(u.ID)
|
||||
org := models.OrgFromUser(o)
|
||||
authorizeLevel, err := org.GetOrgUserMaxAuthorizeLevel(u.ID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetOrgUserAuthorizeLevel", err)
|
||||
return
|
||||
@@ -160,7 +161,7 @@ func GetUserOrgsPermissions(ctx *context.APIContext) {
|
||||
op.IsOwner = true
|
||||
}
|
||||
|
||||
op.CanCreateRepository, err = o.CanCreateOrgRepo(u.ID)
|
||||
op.CanCreateRepository, err = org.CanCreateOrgRepo(u.ID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "CanCreateOrgRepo", err)
|
||||
return
|
||||
@@ -212,7 +213,7 @@ func GetAll(ctx *context.APIContext) {
|
||||
}
|
||||
orgs := make([]*api.Organization, len(publicOrgs))
|
||||
for i := range publicOrgs {
|
||||
orgs[i] = convert.ToOrganization(publicOrgs[i])
|
||||
orgs[i] = convert.ToOrganization(models.OrgFromUser(publicOrgs[i]))
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
|
||||
@@ -252,7 +253,7 @@ func Create(ctx *context.APIContext) {
|
||||
visibility = api.VisibilityModes[form.Visibility]
|
||||
}
|
||||
|
||||
org := &models.User{
|
||||
org := &models.Organization{
|
||||
Name: form.UserName,
|
||||
FullName: form.FullName,
|
||||
Description: form.Description,
|
||||
@@ -295,7 +296,7 @@ func Get(ctx *context.APIContext) {
|
||||
// "200":
|
||||
// "$ref": "#/responses/Organization"
|
||||
|
||||
if !models.HasOrgOrUserVisible(ctx.Org.Organization, ctx.User) {
|
||||
if !models.HasOrgOrUserVisible(ctx.Org.Organization.AsUser(), ctx.User) {
|
||||
ctx.NotFound("HasOrgOrUserVisible", nil)
|
||||
return
|
||||
}
|
||||
@@ -337,7 +338,7 @@ func Edit(ctx *context.APIContext) {
|
||||
if form.RepoAdminChangeTeamAccess != nil {
|
||||
org.RepoAdminChangeTeamAccess = *form.RepoAdminChangeTeamAccess
|
||||
}
|
||||
if err := models.UpdateUserCols(org,
|
||||
if err := models.UpdateUserCols(org.AsUser(),
|
||||
"full_name", "description", "website", "location",
|
||||
"visibility", "repo_admin_change_team_access",
|
||||
); err != nil {
|
||||
|
Reference in New Issue
Block a user