Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the "SessionAdmin" class' readonly_fields with has_add_permission and has_change_permission #21

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions qsessions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -107,3 +94,9 @@ def session_data_decoded(self, obj):
'<pre style="white-space: pre-wrap; max-width: 800px; display: inline-block; direction: ltr;">{}</pre>',
pformat(obj.get_decoded()),
)

def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
return False
Loading