diff options
| author | olivierdalang <olivier.dalang@gmail.com> | 2018-05-02 20:39:12 +1200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-16 06:44:55 -0400 |
| commit | 825f0beda804e48e9197fcf3b0d909f9f548aa47 (patch) | |
| tree | be5036c256efa1cd06a72b3265ed97884afc39cb /tests/admin_views/admin.py | |
| parent | 35b6a348dea6b019679fe35fd443be875bdb028e (diff) | |
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>
Diffstat (limited to 'tests/admin_views/admin.py')
| -rw-r--r-- | tests/admin_views/admin.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 9e6ce63077..51791e961e 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -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): """ |
