mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-05-17 11:41:12 +00:00
Removing old permission handling.
This commit is contained in:
parent
d0635b79c3
commit
8c88362197
1 changed files with 0 additions and 30 deletions
|
|
@ -59,36 +59,6 @@ class BaseAdmin2(object):
|
|||
self.model = model
|
||||
self.admin = admin
|
||||
|
||||
def _user_has_permission(self, user, permission_type, obj=None):
|
||||
""" Generic method for checking whether the user has permission of specified type for the model.
|
||||
Type can be one of view, add, change, delete.
|
||||
You can also specify instance of the model for object-specific permission check.
|
||||
"""
|
||||
if not user.is_authenticated() or not user.is_staff:
|
||||
return False
|
||||
opts = utils.model_options(self.model)
|
||||
full_permission_name = '%s.%s_%s' % (opts.app_label, permission_type, opts.object_name.lower())
|
||||
return user.has_perm(full_permission_name, obj)
|
||||
|
||||
def has_permission(self, request, permission_type, obj=None):
|
||||
return self._user_has_permission(request.user, permission_type, obj)
|
||||
|
||||
def has_view_permission(self, request, obj=None):
|
||||
""" Can view this object """
|
||||
return self.has_permission(request, 'view', obj)
|
||||
|
||||
def has_edit_permission(self, request, obj=None):
|
||||
""" Can edit this object """
|
||||
return self.has_permission(request, 'change', obj)
|
||||
|
||||
def has_add_permission(self, request, obj=None):
|
||||
""" Can add this object """
|
||||
return self.has_permission(request, 'add', obj)
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
""" Can delete this object """
|
||||
return self.has_permission(request, 'delete', obj)
|
||||
|
||||
|
||||
class ModelAdmin2(BaseAdmin2):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue