aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user
diff options
context:
space:
mode:
authorZettat123 <zettat123@gmail.com>2024-10-22 13:09:19 +0800
committerGitHub <noreply@github.com>2024-10-22 13:09:19 +0800
commit9206fbb55fd28f21720072fce6a36cc22277934c (patch)
treef8b99ae96e1446423194ca03032300248b0dd76f /routers/web/user
parent3d6ccbac3f20c485ab95a29d280c9371e558bfac (diff)
downloadgitea-9206fbb55fd28f21720072fce6a36cc22277934c.tar.gz
gitea-9206fbb55fd28f21720072fce6a36cc22277934c.zip
Add `DISABLE_ORGANIZATIONS_PAGE` and `DISABLE_CODE_PAGE` settings for explore pages and fix an issue related to user search (#32288)
These settings can allow users to only display the repositories explore page. Thanks to yp05327 and wxiaoguang ! --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/user')
-rw-r--r--routers/web/user/search.go31
1 files changed, 9 insertions, 22 deletions
diff --git a/routers/web/user/search.go b/routers/web/user/search.go
index fb7729bbe1..be5eee90a9 100644
--- a/routers/web/user/search.go
+++ b/routers/web/user/search.go
@@ -8,37 +8,24 @@ import (
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/optional"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/convert"
)
-// Search search users
-func Search(ctx *context.Context) {
- listOptions := db.ListOptions{
- Page: ctx.FormInt("page"),
- PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
- }
-
- users, maxResults, err := user_model.SearchUsers(ctx, &user_model.SearchUserOptions{
+// SearchCandidates searches candidate users for dropdown list
+func SearchCandidates(ctx *context.Context) {
+ users, _, err := user_model.SearchUsers(ctx, &user_model.SearchUserOptions{
Actor: ctx.Doer,
Keyword: ctx.FormTrim("q"),
- UID: ctx.FormInt64("uid"),
Type: user_model.UserTypeIndividual,
- IsActive: ctx.FormOptionalBool("active"),
- ListOptions: listOptions,
+ IsActive: optional.Some(true),
+ ListOptions: db.ListOptions{PageSize: setting.UI.MembersPagingNum},
})
if err != nil {
- ctx.JSON(http.StatusInternalServerError, map[string]any{
- "ok": false,
- "error": err.Error(),
- })
+ ctx.ServerError("Unable to search users", err)
return
}
-
- ctx.SetTotalCountHeader(maxResults)
-
- ctx.JSON(http.StatusOK, map[string]any{
- "ok": true,
- "data": convert.ToUsers(ctx, ctx.Doer, users),
- })
+ ctx.JSON(http.StatusOK, map[string]any{"data": convert.ToUsers(ctx, ctx.Doer, users)})
}