Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
dd4038fd
Unverified
Commit
dd4038fd
authored
1 year ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Fix user search field in OAuthCredentials admin
parent
b8b650e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2034
Fix user search field in OAuthCredentials admin
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/users/admin.py
+10
-1
10 additions, 1 deletion
arkindex/users/admin.py
with
10 additions
and
1 deletion
arkindex/users/admin.py
+
10
−
1
View file @
dd4038fd
...
...
@@ -127,7 +127,16 @@ class OAuthCredentialAdmin(admin.ModelAdmin):
list_filter
=
[(
'
status
'
,
EnumFieldListFilter
),
]
fields
=
(
'
id
'
,
'
user
'
,
'
token
'
,
'
refresh_token
'
,
'
expiry
'
,
'
status
'
)
readonly_fields
=
(
'
id
'
,
)
search_fields
=
(
'
user
'
,
)
search_fields
=
(
'
searchable_email
'
,
)
def
get_queryset
(
self
,
request
):
qs
=
super
().
get_queryset
(
request
)
qs
=
qs
.
select_related
(
'
user
'
)
# Django's search uses ILIKE, but LIKE is not supported in PostgreSQL with nondeterministic collations.
# We are using a case-insensitive collation to get unique case-insensitive emails, so to search properly,
# we first have to set the collation back to its default value, making it case-sensitive again;
# since Django uses ILIKE, it will be case-insensitive anyway.
return
qs
.
annotate
(
searchable_email
=
Collate
(
'
user__email
'
,
'
default
'
))
admin
.
site
.
register
(
User
,
UserAdmin
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment