From a06690599717927e281c7582bca83b4825a3754e Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 19 Apr 2017 14:00:19 -0400 Subject: [PATCH] fix InvSrc validation Organization requirement for new sources --- awx/api/serializers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 22f3829c5b..30bfd4d4a5 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1471,7 +1471,13 @@ class InventorySourceOptionsSerializer(BaseSerializer): errors['source_script'] = _("If 'source' is 'custom', 'source_script' must be provided.") else: try: - if source_script.organization != self.instance.inventory.organization: + if not self.instance: + dest_inventory = attrs.get('inventory', None) + if not dest_inventory: + errors['inventory'] = _("Must provide an inventory.") + else: + dest_inventory = self.instance.inventory + if source_script.organization != dest_inventory.organization: errors['source_script'] = _("The 'source_script' does not belong to the same organization as the inventory.") except Exception as exc: errors['source_script'] = _("'source_script' doesn't exist.")