From 769704c00930d2e3187bc49406bf9eecc8d6e033 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 31 May 2024 20:19:00 -0600 Subject: [PATCH] Replace the "SessionAdmin" class' readonly_fields with has_add_permission and has_change_permission --- qsessions/admin.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/qsessions/admin.py b/qsessions/admin.py index c2bc170..9d08fd0 100644 --- a/qsessions/admin.py +++ b/qsessions/admin.py @@ -59,19 +59,6 @@ def queryset(self, request, queryset): class SessionAdmin(admin.ModelAdmin): list_display = ("ip", linkify("user"), "is_valid", "created_at", "expire_date", "device", "location") list_select_related = ("user",) - readonly_fields = ( - "ip", - "location", - "user", - "is_valid", - "expire_date", - "created_at", - "updated_at", - "user_agent", - "device", - "session_key", - "session_data_decoded", - ) list_filter = ExpiredFilter, OwnerFilter fields = ( "user", @@ -107,3 +94,9 @@ def session_data_decoded(self, obj): '
{}
', pformat(obj.get_decoded()), ) + + def has_add_permission(self, request): + return False + + def has_change_permission(self, request, obj=None): + return False