mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #8936 -- Added a view permission and a read-only admin.
Co-authored-by: Petr Dlouhy <petr.dlouhy@email.cz> Co-authored-by: Olivier Dalang <olivier.dalang@gmail.com>
This commit is contained in:
committed by
Tim Graham
parent
35b6a348de
commit
825f0beda8
@@ -156,6 +156,10 @@ class RowLevelChangePermissionModelAdmin(admin.ModelAdmin):
|
||||
""" Only allow changing objects with even id number """
|
||||
return request.user.is_staff and (obj is not None) and (obj.id % 2 == 0)
|
||||
|
||||
def has_view_permission(self, request, obj=None):
|
||||
"""Only allow viewing objects if id is a multiple of 3."""
|
||||
return request.user.is_staff and obj is not None and obj.id % 3 == 0
|
||||
|
||||
|
||||
class CustomArticleAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user