mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
fix single update_on_project_update per-inventory
This commit is contained in:
@@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.api.versioning import reverse
|
from awx.api.versioning import reverse
|
||||||
@@ -1394,8 +1395,9 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
|||||||
if self.update_on_project_update is True and \
|
if self.update_on_project_update is True and \
|
||||||
self.source == 'scm' and \
|
self.source == 'scm' and \
|
||||||
InventorySource.objects.filter(
|
InventorySource.objects.filter(
|
||||||
inventory=self.inventory,
|
Q(inventory=self.inventory,
|
||||||
update_on_project_update=True, source='scm').exists():
|
update_on_project_update=True, source='scm') &
|
||||||
|
~Q(id=self.id)).exists():
|
||||||
raise ValidationError(_("Cannot update SCM-based inventory source on launch if set to update on project update. "
|
raise ValidationError(_("Cannot update SCM-based inventory source on launch if set to update on project update. "
|
||||||
"Instead, configure the corresponding source project to update on launch."))
|
"Instead, configure the corresponding source project to update on launch."))
|
||||||
return self.update_on_project_update
|
return self.update_on_project_update
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ class TestSCMClean:
|
|||||||
inv_src1.clean_update_on_project_update()
|
inv_src1.clean_update_on_project_update()
|
||||||
inv_src1.save()
|
inv_src1.save()
|
||||||
|
|
||||||
|
inv_src1.source_vars = '---\nhello: world'
|
||||||
|
inv_src1.clean_update_on_project_update()
|
||||||
|
|
||||||
inv_src2 = InventorySource(inventory=inventory,
|
inv_src2 = InventorySource(inventory=inventory,
|
||||||
update_on_project_update=True,
|
update_on_project_update=True,
|
||||||
source='scm')
|
source='scm')
|
||||||
|
|||||||
Reference in New Issue
Block a user