mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Add in schedule case to helper method, make Activity Stream link point to schedule page
This commit is contained in:
parent
73c87f9512
commit
0dba3f53b1
@ -4682,19 +4682,20 @@ class ActivityStreamSerializer(BaseSerializer):
|
||||
|
||||
def _job_method(self, obj, fk, summary_fields):
|
||||
summary_keys = {'job': 'job_template',
|
||||
'workflow_job_template_node': 'workflow_job_template'}
|
||||
'workflow_job_template_node': 'workflow_job_template',
|
||||
'schedule': 'unified_job_template'}
|
||||
if fk not in summary_keys:
|
||||
return
|
||||
summary_fields[summary_keys[fk]] = []
|
||||
related_obj = getattr(obj, summary_keys[fk], None)
|
||||
summary_fields[get_type_for_model(related_obj)] = []
|
||||
item = {}
|
||||
fields = SUMMARIZABLE_FK_FIELDS[summary_keys[fk]]
|
||||
related_obj = getattr(obj, summary_keys[fk], None)
|
||||
if related_obj is not None:
|
||||
for field in fields:
|
||||
fval = getattr(related_obj, field, None)
|
||||
if fval is not None:
|
||||
item[field] = fval
|
||||
summary_fields[summary_keys[fk]].append(item)
|
||||
summary_fields[get_type_for_model(related_obj)].append(item)
|
||||
|
||||
def get_summary_fields(self, obj):
|
||||
summary_fields = OrderedDict()
|
||||
@ -4706,13 +4707,7 @@ class ActivityStreamSerializer(BaseSerializer):
|
||||
if m2m_list:
|
||||
summary_fields[fk] = []
|
||||
for thisItem in m2m_list:
|
||||
if fk == 'schedule':
|
||||
unified_job_template = getattr(thisItem, 'unified_job_template', None)
|
||||
if unified_job_template is not None:
|
||||
summary_fields[get_type_for_model(unified_job_template)] = {'id': unified_job_template.id,
|
||||
'name': unified_job_template.name}
|
||||
else:
|
||||
self._job_method(thisItem, fk, summary_fields)
|
||||
self._job_method(thisItem, fk, summary_fields)
|
||||
thisItemDict = {}
|
||||
for field in related_fields:
|
||||
fval = getattr(thisItem, field, None)
|
||||
|
||||
@ -39,13 +39,13 @@ export default function BuildAnchor($log, $filter) {
|
||||
case 'schedule':
|
||||
// schedule urls depend on the resource they're associated with
|
||||
if (activity.summary_fields.job_template){
|
||||
url += 'templates/job_template/' + activity.summary_fields.job_template.id + '/schedules/' + obj.id;
|
||||
url += 'templates/job_template/' + activity.summary_fields.job_template[0].id + '/schedules/' + obj.id;
|
||||
}
|
||||
else if (activity.summary_fields.project){
|
||||
url += 'projects/' + activity.summary_fields.project.id + '/schedules/' + obj.id;
|
||||
url += 'projects/' + activity.summary_fields.project[0].id + '/schedules/' + obj.id;
|
||||
}
|
||||
else if (activity.summary_fields.system_job_template){
|
||||
url += 'management_jobs/' + activity.summary_fields.system_job_template.id + '/schedules/edit/' + obj.id;
|
||||
url += 'management_jobs/management_jobs/' + activity.summary_fields.system_job_template[0].id + '/schedules/edit/' + obj.id;
|
||||
}
|
||||
// urls for inventory sync schedules currently depend on having an inventory id and group id
|
||||
else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user