mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 15:57:52 -02:30
Create a default organization.
This commit is contained in:
23
awx/main/management/commands/create_default_org.py
Normal file
23
awx/main/management/commands/create_default_org.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright (c) 2015 Ansible, Inc.
|
||||||
|
# All Rights Reserved
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
from awx.main.models import Organization
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
"""Creates the default organization if and only if no organizations
|
||||||
|
exist in the system.
|
||||||
|
"""
|
||||||
|
help = 'Creates a default organization iff there are none.'
|
||||||
|
|
||||||
|
def handle(self, *args, **kwargs):
|
||||||
|
# Sanity check: Is there already an organization in the system?
|
||||||
|
if Organization.objects.count():
|
||||||
|
return
|
||||||
|
|
||||||
|
# Create a default organization.
|
||||||
|
org, new = Organization.objects.get_or_create(name='Default')
|
||||||
|
if new:
|
||||||
|
print('Default organization added.')
|
||||||
Reference in New Issue
Block a user