diff --git a/AUTHORS b/AUTHORS index e47665e66..deb0c7ce4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ Paul Dekkers Paul Oswald Pavel Tvrdík Peter Carnesciali +Petr Dlouhý Rodney Richardson Rustem Saiargaliev Sandro Rodrigues diff --git a/CHANGELOG.md b/CHANGELOG.md index 36615dcc4..768e577ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * #967 OpenID: Add claims to Well know * #1019 #1024 #1026 #1030 #1033 #1036 [pre-commit.ci] pre-commit autoupdate * #1021 Jazzband: Synced file(s) with jazzband/.github +* #1041 Admin: make extensive fields raw_id, add search fields ## [Changed] * #1022 Replaced pkg_resources usage with importlib.metadata diff --git a/oauth2_provider/admin.py b/oauth2_provider/admin.py index 58b5308fd..bd26dddb1 100644 --- a/oauth2_provider/admin.py +++ b/oauth2_provider/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.contrib.auth import get_user_model from oauth2_provider.models import ( get_access_token_admin_class, @@ -14,6 +15,9 @@ ) +has_email = hasattr(get_user_model(), "email") + + class ApplicationAdmin(admin.ModelAdmin): list_display = ("id", "name", "user", "client_type", "authorization_grant_type") list_filter = ("client_type", "authorization_grant_type", "skip_authorization") @@ -28,6 +32,8 @@ class AccessTokenAdmin(admin.ModelAdmin): list_display = ("token", "user", "application", "expires") list_select_related = ("application", "user") raw_id_fields = ("user", "source_refresh_token") + search_fields = ("token",) + (("user__email",) if has_email else ()) + list_filter = ("application",) class GrantAdmin(admin.ModelAdmin): @@ -38,11 +44,15 @@ class GrantAdmin(admin.ModelAdmin): class IDTokenAdmin(admin.ModelAdmin): list_display = ("jti", "user", "application", "expires") raw_id_fields = ("user",) + search_fields = ("token",) + (("user__email",) if has_email else ()) + list_filter = ("application",) class RefreshTokenAdmin(admin.ModelAdmin): list_display = ("token", "user", "application") raw_id_fields = ("user", "access_token") + search_fields = ("token",) + (("user__email",) if has_email else ()) + list_filter = ("application",) application_model = get_application_model()