Fix OPTIONS permissions bug in groups list

This commit is contained in:
Alan Rominger 2023-02-01 12:07:53 -05:00
parent 93d84fe2c9
commit 6997876da6
No known key found for this signature in database

View File

@ -1027,7 +1027,9 @@ class GroupAccess(BaseAccess):
return Group.objects.filter(inventory__in=Inventory.accessible_pk_qs(self.user, 'read_role'))
def can_add(self, data):
if not data or 'inventory' not in data:
if not data: # So the browseable API will work
return Inventory.accessible_objects(self.user, 'admin_role').exists()
if 'inventory' not in data:
return False
# Checks for admin or change permission on inventory.
return self.check_related('inventory', Inventory, data)