Skip to content

Commit

Permalink
add scm_branch to WFJT prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Aug 15, 2019
1 parent e0751ab commit e51c410
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
16 changes: 11 additions & 5 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3306,12 +3306,13 @@ class WorkflowJobTemplateSerializer(JobTemplateMixin, LabelsListMixin, UnifiedJo
{'copy': 'organization.workflow_admin'}
]
limit = serializers.CharField(allow_blank=True, allow_null=True, required=False, default=None)
scm_branch = serializers.CharField(allow_blank=True, allow_null=True, required=False, default=None)

class Meta:
model = WorkflowJobTemplate
fields = ('*', 'extra_vars', 'organization', 'survey_enabled', 'allow_simultaneous',
'ask_variables_on_launch', 'inventory', 'limit', 'ask_inventory_on_launch',
'ask_limit_on_launch',)
'ask_variables_on_launch', 'inventory', 'limit', 'scm_branch',
'ask_inventory_on_launch', 'ask_scm_branch_on_launch', 'ask_limit_on_launch',)

def get_related(self, obj):
res = super(WorkflowJobTemplateSerializer, self).get_related(obj)
Expand Down Expand Up @@ -3371,13 +3372,14 @@ class Meta:

class WorkflowJobSerializer(LabelsListMixin, UnifiedJobSerializer):
limit = serializers.CharField(allow_blank=True, allow_null=True, required=False, default=None)
scm_branch = serializers.CharField(allow_blank=True, allow_null=True, required=False, default=None)

class Meta:
model = WorkflowJob
fields = ('*', 'workflow_job_template', 'extra_vars', 'allow_simultaneous',
'job_template', 'is_sliced_job',
'-execution_node', '-event_processing_finished', '-controller_node',
'inventory', 'limit',)
'inventory', 'limit', 'scm_branch',)

def get_related(self, obj):
res = super(WorkflowJobSerializer, self).get_related(obj)
Expand Down Expand Up @@ -4164,13 +4166,15 @@ class WorkflowJobLaunchSerializer(BaseSerializer):
required=False, write_only=True
)
limit = serializers.CharField(required=False, write_only=True, allow_blank=True)
scm_branch = serializers.CharField(required=False, write_only=True, allow_blank=True)
workflow_job_template_data = serializers.SerializerMethodField()

class Meta:
model = WorkflowJobTemplate
fields = ('ask_inventory_on_launch', 'ask_limit_on_launch',
fields = ('ask_inventory_on_launch', 'ask_limit_on_launch', 'ask_scm_branch_on_launch',
'can_start_without_user_input', 'defaults', 'extra_vars',
'inventory', 'limit', 'survey_enabled', 'variables_needed_to_start',
'inventory', 'limit', 'scm_branch',
'survey_enabled', 'variables_needed_to_start',
'node_templates_missing', 'node_prompts_rejected',
'workflow_job_template_data', 'survey_enabled', 'ask_variables_on_launch')
read_only_fields = ('ask_inventory_on_launch', 'ask_variables_on_launch')
Expand Down Expand Up @@ -4211,10 +4215,12 @@ def validate(self, attrs):
WFJT_extra_vars = template.extra_vars
WFJT_inventory = template.inventory
WFJT_limit = template.limit
WFJT_scm_branch = template.scm_branch
super(WorkflowJobLaunchSerializer, self).validate(attrs)
template.extra_vars = WFJT_extra_vars
template.inventory = WFJT_inventory
template.limit = WFJT_limit
template.scm_branch = WFJT_scm_branch
return accepted


Expand Down
5 changes: 5 additions & 0 deletions awx/main/migrations/0084_v360_WFJT_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ class Migration(migrations.Migration):
name='ask_limit_on_launch',
field=awx.main.fields.AskForField(blank=True, default=False),
),
migrations.AddField(
model_name='workflowjobtemplate',
name='ask_scm_branch_on_launch',
field=awx.main.fields.AskForField(blank=True, default=False),
),
]
4 changes: 4 additions & 0 deletions awx/main/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ class Meta:
blank=True,
default=False,
)
ask_scm_branch_on_launch = AskForField(
blank=True,
default=False,
)
admin_role = ImplicitRoleField(parent_role=[
'singleton:' + ROLE_SINGLETON_SYSTEM_ADMINISTRATOR,
'organization.workflow_admin_role'
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/unit/models/test_workflow_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,4 @@ def test_no_accepted_project_node_prompts(self, job_node_no_prompts, project_uni


def test_get_ask_mapping_integrity():
assert list(WorkflowJobTemplate.get_ask_mapping().keys()) == ['extra_vars', 'inventory', 'limit']
assert list(WorkflowJobTemplate.get_ask_mapping().keys()) == ['extra_vars', 'inventory', 'limit', 'scm_branch']

0 comments on commit e51c410

Please sign in to comment.