added in logic to check if the parent workflow has a schedule and onsolidated a couple import statements

This commit is contained in:
Rebeccah 2019-09-10 21:27:50 -04:00
parent d3b413c125
commit d39b931377

View File

@ -42,9 +42,9 @@ from awx.main.utils import (
camelcase_to_underscore, get_model_for_type,
encrypt_dict, decrypt_field, _inventory_updates,
copy_model_by_class, copy_m2m_relationships,
get_type_for_model, parse_yaml_or_json, getattr_dne
get_type_for_model, parse_yaml_or_json, getattr_dne,
polymorphic, schedule_task_manager
)
from awx.main.utils import polymorphic, schedule_task_manager
from awx.main.constants import ACTIVE_STATES, CAN_CANCEL
from awx.main.redact import UriCleaner, REPLACE_STR
from awx.main.consumers import emit_channel_notification
@ -1386,9 +1386,13 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
wj = self.get_workflow_job()
if wj:
schedule = getattr_dne(wj, 'schedule')
for name in ('awx', 'tower'):
r['{}_workflow_job_id'.format(name)] = wj.pk
r['{}_workflow_job_name'.format(name)] = wj.name
if schedule:
r['{}_parent_job_schedule_id'.format(name)] = wj.schedule.pk
r['{}_parent_job_schedule_name'.format(name)] = wj.schedule.name
if not created_by:
schedule = getattr_dne(self, 'schedule')