From 6a4f8f9177067b143b16a8e7bb49e8f1ef8c6cf2 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 30 Apr 2015 08:50:42 -0400 Subject: [PATCH] error out if inventory or project not related to relaunched job --- awx/api/serializers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 20810acaff..ba6f4d8acc 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1537,6 +1537,12 @@ class JobRelaunchSerializer(JobSerializer): obj = self.context.get('obj') if not obj.credential or obj.credential.active is False: raise serializers.ValidationError(dict(credential=["Credential not found or deleted."])) + + if obj.job_type != PERM_INVENTORY_SCAN and (obj.project is None or not obj.project.active): + raise serializers.ValidationError(dict(errors=["Job Template Project is missing or undefined"])) + if obj.inventory is None or not obj.inventory.active: + raise serializers.ValidationError(dict(errors=["Job Template Inventory is missing or undefined"])) + return attrs class AdHocCommandSerializer(UnifiedJobSerializer):