mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
Add in schedule case to helper method, make Activity Stream link point to schedule page
This commit is contained in:
@@ -4682,19 +4682,20 @@ class ActivityStreamSerializer(BaseSerializer):
|
|||||||
|
|
||||||
def _job_method(self, obj, fk, summary_fields):
|
def _job_method(self, obj, fk, summary_fields):
|
||||||
summary_keys = {'job': 'job_template',
|
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:
|
if fk not in summary_keys:
|
||||||
return
|
return
|
||||||
summary_fields[summary_keys[fk]] = []
|
related_obj = getattr(obj, summary_keys[fk], None)
|
||||||
|
summary_fields[get_type_for_model(related_obj)] = []
|
||||||
item = {}
|
item = {}
|
||||||
fields = SUMMARIZABLE_FK_FIELDS[summary_keys[fk]]
|
fields = SUMMARIZABLE_FK_FIELDS[summary_keys[fk]]
|
||||||
related_obj = getattr(obj, summary_keys[fk], None)
|
|
||||||
if related_obj is not None:
|
if related_obj is not None:
|
||||||
for field in fields:
|
for field in fields:
|
||||||
fval = getattr(related_obj, field, None)
|
fval = getattr(related_obj, field, None)
|
||||||
if fval is not None:
|
if fval is not None:
|
||||||
item[field] = fval
|
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):
|
def get_summary_fields(self, obj):
|
||||||
summary_fields = OrderedDict()
|
summary_fields = OrderedDict()
|
||||||
@@ -4706,13 +4707,7 @@ class ActivityStreamSerializer(BaseSerializer):
|
|||||||
if m2m_list:
|
if m2m_list:
|
||||||
summary_fields[fk] = []
|
summary_fields[fk] = []
|
||||||
for thisItem in m2m_list:
|
for thisItem in m2m_list:
|
||||||
if fk == 'schedule':
|
self._job_method(thisItem, fk, summary_fields)
|
||||||
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)
|
|
||||||
thisItemDict = {}
|
thisItemDict = {}
|
||||||
for field in related_fields:
|
for field in related_fields:
|
||||||
fval = getattr(thisItem, field, None)
|
fval = getattr(thisItem, field, None)
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ export default function BuildAnchor($log, $filter) {
|
|||||||
case 'schedule':
|
case 'schedule':
|
||||||
// schedule urls depend on the resource they're associated with
|
// schedule urls depend on the resource they're associated with
|
||||||
if (activity.summary_fields.job_template){
|
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){
|
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){
|
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
|
// urls for inventory sync schedules currently depend on having an inventory id and group id
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user