1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Update ObjectPermission evaluation to support null attrs

This commit is contained in:
Jeremy Stretch
2020-05-28 09:39:27 -04:00
parent a261d10bfd
commit 814aff78b5
2 changed files with 14 additions and 8 deletions

View File

@@ -80,7 +80,12 @@ class ObjectPermissionBackend(ModelBackend):
obj_perm_attrs = self.get_object_permissions(user_obj)[perm]
attrs = Q()
for perm_attrs in obj_perm_attrs:
attrs |= Q(**perm_attrs)
if perm_attrs:
attrs |= Q(**perm_attrs)
else:
# Found ObjectPermission with null attrs; allow model-level access
attrs = Q()
break
# Permission to perform the requested action on the object depends on whether the specified object matches
# the specified attributes. Note that this check is made against the *database* record representing the object,