From 0d56f42c837d06804cdad6045104ca73d914b81e Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 5 Jun 2017 13:43:09 -0400 Subject: [PATCH] better insights_credential reverse relationship * From an insights cred, access all related inventories via cred.insights_inventories rather than cred.insights_credential * This fixes auto-attaching insights_credential to credential summary fields. Fixes by NOT attaching them. That is the desired behavior. --- awx/main/migrations/0038_v320_release.py | 2 +- awx/main/models/inventory.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/main/migrations/0038_v320_release.py b/awx/main/migrations/0038_v320_release.py index dab523fd16..38df95682f 100644 --- a/awx/main/migrations/0038_v320_release.py +++ b/awx/main/migrations/0038_v320_release.py @@ -269,7 +269,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='inventory', name='insights_credential', - field=models.ForeignKey(related_name='insights_credential', default=None, blank=True, on_delete=models.deletion.SET_NULL, to='main.Credential', help_text='Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.', null=True), + field=models.ForeignKey(related_name='insights_inventories', on_delete=models.deletion.SET_NULL, default=None, blank=True, to='main.Credential', help_text='Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.', null=True), ), migrations.AlterField( model_name='inventory', diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index a41b166e94..4bd551f678 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -146,7 +146,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin): ]) insights_credential = models.ForeignKey( 'Credential', - related_name='insights_credential', + related_name='insights_inventories', help_text=_('Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.'), on_delete=models.SET_NULL, blank=True,