Skip to content

Commit

Permalink
Add accesstoken and ThrottledApplication to admin panel (#3836)
Browse files Browse the repository at this point in the history
* Add accesstoken and ThrottledApplication to admin panel (#3711)

Co-authored-by: Tore Nylén <toreny@kth.se>
Co-authored-by: Oozna <66669398+Oozna@users.noreply.github.com>
Co-authored-by: Sam Shahriari <62112476+samshahriari@users.noreply.github.com>
Co-authored-by: Sam <80268884+Samkth123@users.noreply.github.com>

* resolve import merge conflict (#5711)

* resolve review comments (#3711)

* make rate_limit_model searchable (#3711)

---------

Co-authored-by: Tore Nylén <toreny@kth.se>
Co-authored-by: Oozna <66669398+Oozna@users.noreply.github.com>
Co-authored-by: Sam Shahriari <62112476+samshahriari@users.noreply.github.com>
Co-authored-by: Sam <80268884+Samkth123@users.noreply.github.com>
  • Loading branch information
5 people authored Mar 19, 2024
1 parent fcad99d commit 697c178
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.models import Group, User

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 @@ -90,3 +93,44 @@ 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", "rate_limit_model")
list_display = ("client_id", "name", "created", "rate_limit_model")
ordering = ("-created",)

readonly_fields = (
"skip_authorization",
"verified",
"client_id",
"name",
"user",
"algorithm",
"redirect_uris",
"post_logout_redirect_uris",
"client_type",
"authorization_grant_type",
"client_secret",
)


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

readonly_fields = (
"id",
"user",
"source_refresh_token",
"token",
"id_token",
"application",
"expires",
"scope",
"created",
"updated",
)

0 comments on commit 697c178

Please sign in to comment.