Force custom inventory script organization to match the organization of

an inventory source's inventory when creating/updating the inventory source
This commit is contained in:
Matthew Jones
2014-12-16 13:00:33 -05:00
parent b0d6628d46
commit 76a7d25131
2 changed files with 18 additions and 0 deletions

View File

@@ -1020,6 +1020,11 @@ class InventorySourceOptionsSerializer(BaseSerializer):
if 'source' in attrs and attrs.get('source', '') == 'custom':
if src is None or src == '':
raise serializers.ValidationError("source_script must be provided")
try:
if src.organization != self.object.inventory.organization:
raise serializers.ValidationError("source_script does not belong to the same organization as the inventory")
except Exception, e:
raise serializers.ValidationError("source_script doesn't exist")
return attrs
def validate_source_vars(self, attrs, source):