Skip to content

Commit

Permalink
[ BB2-821 ] Improve Django ADMIN view performance (#967)
Browse files Browse the repository at this point in the history
* optimize application view: remove app name filter and user name filter, add app name and user name etc. as searchables.

* app name search by icontains instead of startwith.

* remove filters on user name and app name.

* make source refresh token searchable per PR review.
  • Loading branch information
JFU-GIT authored Sep 17, 2021
1 parent d225edf commit db21fb8
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions apps/dot_ext/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,47 +76,41 @@ def clean_agree(self):
return self.cleaned_data.get('agree')


@admin.register(MyApplication)
class MyApplicationAdmin(admin.ModelAdmin):
form = CustomAdminApplicationForm
list_display = ("name", "user", "authorization_grant_type", "client_id",
"require_demographic_scopes", "scopes",
"created", "updated", "active", "skip_authorization")
list_filter = ("name", "user", "client_type", "authorization_grant_type",
list_filter = ("client_type", "authorization_grant_type",
"require_demographic_scopes", "active", "skip_authorization")
radio_fields = {
"client_type": admin.HORIZONTAL,
"authorization_grant_type": admin.VERTICAL,
}
raw_id_fields = ("user", )

search_fields = ('name', 'user__username', '=client_id', '=require_demographic_scopes', '=authorization_grant_type')

admin.site.register(MyApplication, MyApplicationAdmin)
raw_id_fields = ("user", )


@admin.register(MyAccessToken)
class MyAccessTokenAdmin(admin.ModelAdmin):
list_display = ('user', 'application', 'expires', 'scope')
search_fields = ('user__username', 'application__name',)
list_filter = ("user", "application")
list_display = ('user', 'application', 'expires', 'scope', 'token',)
search_fields = ('user__username', 'application__name', 'token', 'source_refresh_token__token')
raw_id_fields = ("user", 'application')


admin.site.register(MyAccessToken, MyAccessTokenAdmin)


@admin.register(MyAuthFlowUuid)
class MyAuthFlowUuidAdmin(admin.ModelAdmin):
list_display = ('created', 'auth_uuid', 'state', 'code', 'client_id',
'auth_pkce_method', 'auth_crosswalk_action', 'auth_share_demographic_scopes')
search_fields = ('auth_uuid', 'state', 'code')


admin.site.register(MyAuthFlowUuid, MyAuthFlowUuidAdmin)


@admin.register(ApplicationLabel)
class ApplicationLabelAdmin(admin.ModelAdmin):
model = ApplicationLabel
filter_horizontal = ('applications',)
list_display = ("name", "slug", "short_description")
list_filter = ("name", "slug")


admin.site.register(ApplicationLabel, ApplicationLabelAdmin)

0 comments on commit db21fb8

Please sign in to comment.