Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accesstoken and ThrottledApplication to admin panel #3836

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from django.contrib import admin

from oauth2_provider.models import AccessToken

from api.admin.site import openverse_admin
from api.models import PENDING, Audio, AudioReport, ContentProvider, Image, ImageReport
from api.models.media import AbstractDeletedMedia, AbstractSensitiveMedia
from api.models.oauth import ThrottledApplication


admin.site = openverse_admin
Expand Down Expand Up @@ -83,3 +86,54 @@ class ProviderAdmin(admin.ModelAdmin):
list_display = ("provider_name", "provider_identifier", "media_type")
search_fields = ("provider_name", "provider_identifier")
ordering = ("media_type", "provider_name")


@admin.register(ThrottledApplication)
class ThrottledApplicationAdmin(admin.ModelAdmin):
search_fields = ("client_id", "name")
list_display = ("client_id", "name", "user", "rate_limit_model")
ordering = ("client_id",)
krysal marked this conversation as resolved.
Show resolved Hide resolved

def get_readonly_fields(self, request, obj=None):
krysal marked this conversation as resolved.
Show resolved Hide resolved
if obj is None:
return []
readonly_fields = [
"skip_authorization",
"verified",
"client_id",
"name",
"user",
"rate_limit_model",
"algorithm",
"redirect_uris",
"post_logout_redirect_uris",
"client_type",
"authorization_grant_type",
"client_secret",
]

return readonly_fields


@admin.register(AccessToken)
class AccessTokenAdmin(admin.ModelAdmin):
search_fields = ("token", "id")
list_display = ("token", "id", "scope", "expires")

def get_readonly_fields(self, request, obj=None):
if obj is None:
return []
readonly_fields = [
"id",
"user",
"source_refresh_token",
"token",
"id_token",
"application",
"expires",
"scope",
"created",
"updated",
]

return readonly_fields
Loading