diff options
Diffstat (limited to 'routers/web/user')
-rw-r--r-- | routers/web/user/profile.go | 7 | ||||
-rw-r--r-- | routers/web/user/setting/profile.go | 26 |
2 files changed, 29 insertions, 4 deletions
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 72d36761da..9d0b4e3c15 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -167,9 +167,12 @@ func Profile(ctx *context.Context) { showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID) - orgs, err := models.GetOrgsByUserID(ctxUser.ID, showPrivate) + orgs, err := models.FindOrgs(models.FindOrgOptions{ + UserID: ctxUser.ID, + IncludePrivate: showPrivate, + }) if err != nil { - ctx.ServerError("GetOrgsByUserIDDesc", err) + ctx.ServerError("FindOrgs", err) return } diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index d7aa3264c5..36fe45df04 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -214,12 +214,34 @@ func DeleteAvatar(ctx *context.Context) { func Organization(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsOrganization"] = true - orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned) + + opts := models.FindOrgOptions{ + ListOptions: db.ListOptions{ + PageSize: setting.UI.Admin.UserPagingNum, + Page: ctx.FormInt("page"), + }, + UserID: ctx.User.ID, + IncludePrivate: ctx.IsSigned, + } + + if opts.Page <= 0 { + opts.Page = 1 + } + + orgs, err := models.FindOrgs(opts) + if err != nil { + ctx.ServerError("FindOrgs", err) + return + } + total, err := models.CountOrgs(opts) if err != nil { - ctx.ServerError("GetOrgsByUserID", err) + ctx.ServerError("CountOrgs", err) return } ctx.Data["Orgs"] = orgs + pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5) + pager.SetDefaultParams(ctx) + ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, tplSettingsOrganization) } |