From d6153aabbe4e3b3aee4c969e5d5a8ee563d3ed24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 11 Jan 2022 12:02:49 +0100 Subject: [PATCH 1/2] fix #1083 ('token' not valid search field), add search fields to all remaining admin classes --- oauth2_provider/admin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oauth2_provider/admin.py b/oauth2_provider/admin.py index bd26dddb1..f543de824 100644 --- a/oauth2_provider/admin.py +++ b/oauth2_provider/admin.py @@ -25,6 +25,7 @@ class ApplicationAdmin(admin.ModelAdmin): "client_type": admin.HORIZONTAL, "authorization_grant_type": admin.VERTICAL, } + search_fields = ("name",) + (("user__email",) if has_email else ()) raw_id_fields = ("user",) @@ -39,12 +40,13 @@ class AccessTokenAdmin(admin.ModelAdmin): class GrantAdmin(admin.ModelAdmin): list_display = ("code", "application", "user", "expires") raw_id_fields = ("user",) + search_fields = ("code",) + (("user__email",) if has_email else ()) class IDTokenAdmin(admin.ModelAdmin): list_display = ("jti", "user", "application", "expires") raw_id_fields = ("user",) - search_fields = ("token",) + (("user__email",) if has_email else ()) + search_fields = (("user__email",) if has_email else ()) list_filter = ("application",) From 2a85e0a6d40ed9f98cbf61dcc1a1ee303a0dc4fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:10:19 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- oauth2_provider/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oauth2_provider/admin.py b/oauth2_provider/admin.py index f543de824..cf41ec5b2 100644 --- a/oauth2_provider/admin.py +++ b/oauth2_provider/admin.py @@ -46,7 +46,7 @@ class GrantAdmin(admin.ModelAdmin): class IDTokenAdmin(admin.ModelAdmin): list_display = ("jti", "user", "application", "expires") raw_id_fields = ("user",) - search_fields = (("user__email",) if has_email else ()) + search_fields = ("user__email",) if has_email else () list_filter = ("application",)