aboutsummaryrefslogtreecommitdiffstats
path: root/django/cms/migrations/0002_user_application.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/cms/migrations/0002_user_application.py')
-rw-r--r--[-rwxr-xr-x]django/cms/migrations/0002_user_application.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/django/cms/migrations/0002_user_application.py b/django/cms/migrations/0002_user_application.py
index b0e8e1f..42b26c0 100755..100644
--- a/django/cms/migrations/0002_user_application.py
+++ b/django/cms/migrations/0002_user_application.py
@@ -1,4 +1,4 @@
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
@@ -38,11 +38,12 @@
from __future__ import unicode_literals
from django.db import migrations
from django.contrib.auth import get_user_model
-from oauth2_provider.models import get_application_model, Application
+from oauth2_provider.models import get_application_model
from django.conf import settings
-#This migration file creates default admin user for the mezzanine server and default EM client app and default categories
+# This migration file creates default admin user for the mezzanine server
+# and default EM client app and default categories
DEFAULT_USERNAME = settings.CMS_APP_USER
DEFAULT_PASSWORD = settings.CMS_APP_USER_PASSWORD
@@ -54,6 +55,8 @@ CMS_APP_NAME = settings.CMS_APP_NAME
'''
Create the admin user for the CSM server
'''
+
+
def create_emuser(apps, schema_editor):
User = get_user_model()
args = (DEFAULT_USERNAME, DEFAULT_EMAIL, DEFAULT_PASSWORD)
@@ -62,34 +65,39 @@ def create_emuser(apps, schema_editor):
except:
User.objects.create_superuser(*args)
+
'''
Create the EM application which acts as a client to the CSM server
'''
+
+
def create_emapp(apps, schema_editor):
Application = get_application_model()
- application=None
+ application = None
try:
application = Application.objects.get(client_id=DEFAULT_CLIENT_ID)
except:
- # If client_secret and client_id not supplied, a unique one will be generated
+ # If client_secret and client_id not supplied, a unique one will be
+ # generated
application = Application.objects.create(
- name=CMS_APP_NAME,
- client_type=Application.CLIENT_CONFIDENTIAL,
- authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS,
- client_secret=DEFAULT_CLIENT_SECRET,
- client_id=DEFAULT_CLIENT_ID,
- )
- print("Created ICE application="+str(application))
+ name=CMS_APP_NAME,
+ client_type=Application.CLIENT_CONFIDENTIAL,
+ authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS,
+ client_secret=DEFAULT_CLIENT_SECRET,
+ client_id=DEFAULT_CLIENT_ID,
+ )
+ print("Created ICE application=" + str(application))
+
class Migration(migrations.Migration):
-
- dependencies = [ ('cms', '0001_initial'),
- ('twitter' , '0001_initial' ),
- ('oauth2_provider' , '0004_auto_20160525_1623'),
- ]
+
+ dependencies = [('cms', '0001_initial'),
+ ('twitter', '0001_initial'),
+ ('oauth2_provider', '0004_auto_20160525_1623'),
+ ]
operations = [
- migrations.RunPython(create_emapp),
- migrations.RunPython(create_emuser),
+ migrations.RunPython(create_emapp),
+ migrations.RunPython(create_emuser),
]