Exemplo n.º 1
0
def getEffectivePermission(user, obj, root=False):
    if user.is_admin is True:
        return PERMISSION_ALL

    if user.staff_member is False:
        return PERMISSION_NONE

    if root is False:
        return Permissions.getPermissions(user=user, groups=user.groups.all(), object_type=ot.getObjectType(obj), object_id=obj.pk)
    else:
        return Permissions.getPermissions(user=user, groups=user.groups.all(), object_type=ot.getObjectType(obj))
Exemplo n.º 2
0
def getEffectivePermission(user, obj, root=False):
    if user.is_admin is True:
        return PERMISSION_ALL

    if user.staff_member is False:
        return PERMISSION_NONE

    if root is False:
        return Permissions.getPermissions(user=user, groups=user.groups.all(), object_type=ot.getObjectType(obj), object_id=obj.pk)
    else:
        return Permissions.getPermissions(user=user, groups=user.groups.all(), object_type=ot.getObjectType(obj))
Exemplo n.º 3
0
def getPermissionName(perm):
    return Permissions.permissionAsString(perm)
Exemplo n.º 4
0
def addGroupPermission(group, obj, permission=PERMISSION_READ):
    Permissions.addPermission(group=group,
                              object_type=ot.getObjectType(obj),
                              object_id=obj.pk,
                              permission=permission)
Exemplo n.º 5
0
def addUserPermission(user, obj, permission=PERMISSION_READ):
    # Some permissions added to some object types needs at least READ_PERMISSION on parent
    Permissions.addPermission(user=user,
                              object_type=ot.getObjectType(obj),
                              object_id=obj.pk,
                              permission=permission)
Exemplo n.º 6
0
def getPermissions(obj):
    return list(
        Permissions.enumeratePermissions(object_type=ot.getObjectType(obj),
                                         object_id=obj.pk))
Exemplo n.º 7
0
def clean(obj):
    Permissions.cleanPermissions(ot.getObjectType(obj), obj.pk)
Exemplo n.º 8
0
def getPermissionName(perm):
    return Permissions.permissionAsString(perm)
Exemplo n.º 9
0
def addGroupPermission(group, obj, permission=PERMISSION_READ):
    Permissions.addPermission(group=group, object_type=ot.getObjectType(obj), object_id=obj.pk, permission=permission)
Exemplo n.º 10
0
def addUserPermission(user, obj, permission=PERMISSION_READ):
    # Some permissions added to some object types needs at least READ_PERMISSION on parent
    Permissions.addPermission(user=user, object_type=ot.getObjectType(obj), object_id=obj.pk, permission=permission)
Exemplo n.º 11
0
def getPermissions(obj):
    return list(Permissions.enumeratePermissions(object_type=ot.getObjectType(obj), object_id=obj.pk))
Exemplo n.º 12
0
def clean(obj):
    Permissions.cleanPermissions(ot.getObjectType(obj), obj.pk)