mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 15:08:03 -03:30
Avoid Project..get_or_create() in create_preload_data
Django ORM method get_or_create() does not call save() directly, but it calls the create() [1]. The create method ignores the skip_update=True option, which then will trigger a project update, however the EE was not yet created in the database. To avoid this problem, we just check the existence of the default project and creates it with save(skip_update=True) manually.
This commit is contained in:
parent
85cc67fb4e
commit
7ae6286152
@ -25,13 +25,17 @@ class Command(BaseCommand):
|
||||
if not Organization.objects.exists():
|
||||
o, _ = Organization.objects.get_or_create(name='Default')
|
||||
|
||||
p, _ = Project.objects.get_or_create(
|
||||
name='Demo Project',
|
||||
scm_type='git',
|
||||
scm_url='https://github.com/ansible/ansible-tower-samples',
|
||||
scm_update_on_launch=True,
|
||||
scm_update_cache_timeout=0,
|
||||
)
|
||||
# Avoid calling directly the get_or_create() to bypass project update
|
||||
p = Project.objects.filter(name='Demo Project', scm_type='git').first()
|
||||
if not p:
|
||||
p = Project(
|
||||
name='Demo Project',
|
||||
scm_type='git',
|
||||
scm_url='https://github.com/ansible/ansible-tower-samples',
|
||||
scm_update_on_launch=True,
|
||||
scm_update_cache_timeout=0,
|
||||
)
|
||||
|
||||
p.organization = o
|
||||
p.save(skip_update=True)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user