mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Ensure workflow_job_template being set during node creation.
This commit is contained in:
@@ -2322,6 +2322,8 @@ class WorkflowJobTemplateNodeSerializer(WorkflowNodeBaseSerializer):
|
|||||||
raise serializers.ValidationError({
|
raise serializers.ValidationError({
|
||||||
"job_type": "%s is not a valid job type. The choices are %s." % (
|
"job_type": "%s is not a valid job type. The choices are %s." % (
|
||||||
attrs['char_prompts']['job_type'], job_types)})
|
attrs['char_prompts']['job_type'], job_types)})
|
||||||
|
if self.instance is None and 'workflow_job_template' not in attrs:
|
||||||
|
raise serializers.ValidationError({"workflow_job_template": "Workflow job template is missing during creation"})
|
||||||
ujt_obj = attrs.get('unified_job_template', None)
|
ujt_obj = attrs.get('unified_job_template', None)
|
||||||
if isinstance(ujt_obj, (WorkflowJobTemplate, SystemJobTemplate)):
|
if isinstance(ujt_obj, (WorkflowJobTemplate, SystemJobTemplate)):
|
||||||
raise serializers.ValidationError({
|
raise serializers.ValidationError({
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ class WorkflowNodeBase(CreatedModifiedModel):
|
|||||||
'inventory', 'credential', 'char_prompts']
|
'inventory', 'credential', 'char_prompts']
|
||||||
|
|
||||||
class WorkflowJobTemplateNode(WorkflowNodeBase):
|
class WorkflowJobTemplateNode(WorkflowNodeBase):
|
||||||
# TODO: Ensure the API forces workflow_job_template being set
|
|
||||||
workflow_job_template = models.ForeignKey(
|
workflow_job_template = models.ForeignKey(
|
||||||
'WorkflowJobTemplate',
|
'WorkflowJobTemplate',
|
||||||
related_name='workflow_job_template_nodes',
|
related_name='workflow_job_template_nodes',
|
||||||
@@ -149,7 +148,7 @@ class WorkflowJobTemplateNode(WorkflowNodeBase):
|
|||||||
default=None,
|
default=None,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('api:workflow_job_template_node_detail', args=(self.pk,))
|
return reverse('api:workflow_job_template_node_detail', args=(self.pk,))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user