mirror of
https://github.com/ansible/awx.git
synced 2026-03-25 21:05:03 -02:30
Merge pull request #180 from chrismeyersfsu/fix-7383
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.core.exceptions import ValidationError
|
||||
from django.utils.timezone import now
|
||||
from django.db.models import Q
|
||||
|
||||
# AWX
|
||||
from awx.api.versioning import reverse
|
||||
@@ -1396,12 +1397,20 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
||||
if self.update_on_project_update is True and \
|
||||
self.source == 'scm' and \
|
||||
InventorySource.objects.filter(
|
||||
inventory=self.inventory,
|
||||
update_on_project_update=True, source='scm').exists():
|
||||
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."))
|
||||
Q(inventory=self.inventory,
|
||||
update_on_project_update=True, source='scm') &
|
||||
~Q(id=self.id)).exists():
|
||||
raise ValidationError(_("More than one SCM-based inventory source with update on project update on per-inventory not allowed."))
|
||||
return self.update_on_project_update
|
||||
|
||||
def clean_update_on_launch(self):
|
||||
if self.update_on_project_update is True and \
|
||||
self.source == 'scm' and \
|
||||
self.update_on_launch is True:
|
||||
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."))
|
||||
return self.update_on_launch
|
||||
|
||||
def clean_overwrite_vars(self):
|
||||
if self.source == 'scm' and not self.overwrite_vars:
|
||||
raise ValidationError(_("SCM type sources must set `overwrite_vars` to `true`."))
|
||||
|
||||
Reference in New Issue
Block a user