diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-19 19:41:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 19:41:40 +0800 |
commit | 7a0347315995b25bcb2dca4786504fb699b5f004 (patch) | |
tree | 803dfd39286216fd0521ad16539ffd9fc5f87fc0 /routers/web/org/setting.go | |
parent | a09b40de8d1dae7107437cfba42cee201fcd6d42 (diff) | |
download | gitea-7a0347315995b25bcb2dca4786504fb699b5f004.tar.gz gitea-7a0347315995b25bcb2dca4786504fb699b5f004.zip |
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>
Diffstat (limited to 'routers/web/org/setting.go')
-rw-r--r-- | routers/web/org/setting.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index f27cb40838..f05dbd8bc1 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -68,7 +68,7 @@ func SettingsPost(ctx *context.Context) { ctx.Data["OrgName"] = true ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form) return - } else if err = models.ChangeUserName(org, form.Name); err != nil { + } else if err = models.ChangeUserName(org.AsUser(), form.Name); err != nil { if err == models.ErrUserNameIllegal { ctx.Data["OrgName"] = true ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form) @@ -100,18 +100,20 @@ func SettingsPost(ctx *context.Context) { visibilityChanged := form.Visibility != org.Visibility org.Visibility = form.Visibility - if err := models.UpdateUser(org); err != nil { + if err := models.UpdateUser(org.AsUser()); err != nil { ctx.ServerError("UpdateUser", err) return } // update forks visibility if visibilityChanged { - if err := org.GetRepositories(db.ListOptions{Page: 1, PageSize: org.NumRepos}); err != nil { + repos, _, err := models.GetUserRepositories(&models.SearchRepoOptions{ + Actor: org.AsUser(), Private: true, ListOptions: db.ListOptions{Page: 1, PageSize: org.NumRepos}}) + if err != nil { ctx.ServerError("GetRepositories", err) return } - for _, repo := range org.Repos { + for _, repo := range repos { repo.OwnerName = org.Name if err := models.UpdateRepository(repo, true); err != nil { ctx.ServerError("UpdateRepository", err) @@ -134,7 +136,7 @@ func SettingsPost(ctx *context.Context) { func SettingsAvatar(ctx *context.Context) { form := web.GetForm(ctx).(*forms.AvatarForm) form.Source = forms.AvatarLocal - if err := userSetting.UpdateAvatarSetting(ctx, form, ctx.Org.Organization); err != nil { + if err := userSetting.UpdateAvatarSetting(ctx, form, ctx.Org.Organization.AsUser()); err != nil { ctx.Flash.Error(err.Error()) } else { ctx.Flash.Success(ctx.Tr("org.settings.update_avatar_success")) @@ -145,7 +147,7 @@ func SettingsAvatar(ctx *context.Context) { // SettingsDeleteAvatar response for delete avatar on settings page func SettingsDeleteAvatar(ctx *context.Context) { - if err := ctx.Org.Organization.DeleteAvatar(); err != nil { + if err := ctx.Org.Organization.AsUser().DeleteAvatar(); err != nil { ctx.Flash.Error(err.Error()) } |