Skip to content

Commit

Permalink
Jump directly into the single user preferences entry from list view
Browse files Browse the repository at this point in the history
  • Loading branch information
AetherUnbound committed Mar 21, 2024
1 parent df81193 commit 8fd2c14
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.contrib import admin
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.models import Group, User
from django.http.response import HttpResponseRedirect
from django.urls import reverse

from oauth2_provider.models import AccessToken

Expand Down Expand Up @@ -166,3 +168,9 @@ def has_change_permission(self, request, obj=None):
# the changelist itself
return True
return obj.user == request.user

def changelist_view(self, request, extra_context=None):
obj = self.get_queryset(request).first()
return HttpResponseRedirect(
reverse("admin:api_userpreferences_change", args=[obj.id])
)

0 comments on commit 8fd2c14

Please sign in to comment.