From 198a9ca6350954a6d3327a408021fec2bc0fc805 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 14 Sep 2023 14:53:36 +0800 Subject: Display all user types and org types on admin management UI (#27050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow #24026 图片 --------- Co-authored-by: delvh --- models/user/search.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'models/user') diff --git a/models/user/search.go b/models/user/search.go index bf35fcd9eb..446556f89b 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -34,12 +34,26 @@ type SearchUserOptions struct { IsRestricted util.OptionalBool IsTwoFactorEnabled util.OptionalBool IsProhibitLogin util.OptionalBool + IncludeReserved bool ExtraParamStrings map[string]string } func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { - var cond builder.Cond = builder.Eq{"type": opts.Type} + var cond builder.Cond + cond = builder.Eq{"type": opts.Type} + if opts.IncludeReserved { + if opts.Type == UserTypeIndividual { + cond = cond.Or(builder.Eq{"type": UserTypeUserReserved}).Or( + builder.Eq{"type": UserTypeBot}, + ).Or( + builder.Eq{"type": UserTypeRemoteUser}, + ) + } else if opts.Type == UserTypeOrganization { + cond = cond.Or(builder.Eq{"type": UserTypeOrganizationReserved}) + } + } + if len(opts.Keyword) > 0 { lowerKeyword := strings.ToLower(opts.Keyword) keywordCond := builder.Or( -- cgit v1.2.3