Impersonation system implementation

This commit is contained in:
JakeBreath
2026-08-03 21:33:31 -05:00
parent 87b0d46232
commit 95acc9b8d2
12 changed files with 545 additions and 8 deletions
+19 -2
View File
@@ -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