Impersonation system implementation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import ApiToken, UserProfile
|
||||
from .models import ApiToken, ImpersonationLog, UserProfile
|
||||
|
||||
|
||||
@admin.register(UserProfile)
|
||||
@@ -12,4 +12,21 @@ class UserProfileAdmin(admin.ModelAdmin):
|
||||
@admin.register(ApiToken)
|
||||
class ApiTokenAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'label', 'key_prefix', 'created_at', 'last_used')
|
||||
search_fields = ('user__username', 'label')
|
||||
search_fields = ('user__username', 'label')
|
||||
|
||||
|
||||
@admin.register(ImpersonationLog)
|
||||
class ImpersonationLogAdmin(admin.ModelAdmin):
|
||||
list_display = ('impersonator', 'target', 'reason', 'started_at', 'ended_at')
|
||||
list_filter = ('started_at', 'ended_at')
|
||||
search_fields = ('impersonator__username', 'target__username', 'reason')
|
||||
readonly_fields = ('impersonator', 'target', 'reason', 'started_at', 'ended_at')
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return False
|
||||
|
||||
def has_change_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return request.user.is_superuser
|
||||
Reference in New Issue
Block a user