Merge pull request #2922 from wwitzel3/issue-2508

ensure CustomInventoryScripts render correctly in the ActivityStream
This commit is contained in:
Wayne Witzel III 2016-07-12 08:28:43 -04:00 committed by GitHub
commit f9707c0ca1
2 changed files with 7 additions and 1 deletions

View File

@ -87,6 +87,7 @@ SUMMARIZABLE_FK_FIELDS = {
'current_update': DEFAULT_SUMMARY_FIELDS + ('status', 'failed', 'license_error'),
'current_job': DEFAULT_SUMMARY_FIELDS + ('status', 'failed', 'license_error'),
'inventory_source': ('source', 'last_updated', 'status'),
'custom_inventory_script': DEFAULT_SUMMARY_FIELDS,
'source_script': ('name', 'description'),
'role': ('id', 'role_field'),
'notification_template': DEFAULT_SUMMARY_FIELDS,
@ -2620,7 +2621,11 @@ class ActivityStreamSerializer(BaseSerializer):
if getattr(obj, fk).exists():
rel[fk] = []
for thisItem in allm2m:
rel[fk].append(reverse('api:' + fk + '_detail', args=(thisItem.id,)))
if fk == 'custom_inventory_script':
rel[fk].append(reverse('api:inventory_script_detail', args=(thisItem.id,)))
else:
rel[fk].append(reverse('api:' + fk + '_detail', args=(thisItem.id,)))
if fk == 'schedule':
rel['unified_job_template'] = thisItem.unified_job_template.get_absolute_url()
return rel

View File

@ -323,6 +323,7 @@ model_serializer_mapping = {
Host: HostSerializer,
Group: GroupSerializer,
InventorySource: InventorySourceSerializer,
CustomInventoryScript: CustomInventoryScriptSerializer,
Credential: CredentialSerializer,
Team: TeamSerializer,
Project: ProjectSerializer,