diff options
author | zeripath <art27@cantab.net> | 2019-05-15 16:24:39 +0100 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-05-15 11:24:39 -0400 |
commit | 56ae539bed7d822980ebaae8db316a0177fc028c (patch) | |
tree | ee63a75ba156002cb6c40975c1c35b032954f913 /routers/user/home.go | |
parent | 5fb1ad70113d3272232c266b4ff58e9f7f646594 (diff) | |
download | gitea-56ae539bed7d822980ebaae8db316a0177fc028c.tar.gz gitea-56ae539bed7d822980ebaae8db316a0177fc028c.zip |
SearchRepositoryByName improvements and unification (#6897)
Diffstat (limited to 'routers/user/home.go')
-rw-r--r-- | routers/user/home.go | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/routers/user/home.go b/routers/user/home.go index b53a47db94..9ccd5bdb26 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -499,50 +499,20 @@ func showOrgProfile(ctx *context.Context) { count int64 err error ) - if ctx.IsSigned && !ctx.User.IsAdmin { - env, err := org.AccessibleReposEnv(ctx.User.ID) - if err != nil { - ctx.ServerError("AccessibleReposEnv", err) - return - } - env.SetSort(orderBy) - if len(keyword) != 0 { - env.AddKeyword(keyword) - } - repos, err = env.Repos(page, setting.UI.User.RepoPagingNum) - if err != nil { - ctx.ServerError("env.Repos", err) - return - } - count, err = env.CountRepos() - if err != nil { - ctx.ServerError("env.CountRepos", err) - return - } - } else { - showPrivate := ctx.IsSigned && ctx.User.IsAdmin - if len(keyword) == 0 { - repos, err = models.GetUserRepositories(org.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy.String()) - if err != nil { - ctx.ServerError("GetRepositories", err) - return - } - count = models.CountUserRepositories(org.ID, showPrivate) - } else { - repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ - Keyword: keyword, - OwnerID: org.ID, - OrderBy: orderBy, - Private: showPrivate, - Page: page, - IsProfile: true, - PageSize: setting.UI.User.RepoPagingNum, - }) - if err != nil { - ctx.ServerError("SearchRepositoryByName", err) - return - } - } + repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ + Keyword: keyword, + OwnerID: org.ID, + OrderBy: orderBy, + Private: ctx.IsSigned, + UserIsAdmin: ctx.IsUserSiteAdmin(), + UserID: ctx.Data["SignedUserID"].(int64), + Page: page, + IsProfile: true, + PageSize: setting.UI.User.RepoPagingNum, + }) + if err != nil { + ctx.ServerError("SearchRepositoryByName", err) + return } if err := org.GetMembers(); err != nil { |