All repo files were edited according to pep8 standards.
Verification conducted using flake8.
Change-Id: I661e2551d16bd833b227d3e246a5ff63ad639db1
Issue-Id: VVP-25
Signed-off-by: Amir Skalka <as221v@intl.att.com>
+# ============LICENSE_START==========================================
+# org.onap.vvp/image-scanner
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
# rkt-ice-cms
+
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
import os
+
def envbool(key, default=False, unknown=True):
"""Return a boolean value based on that of an environment variable.
- Environment variables have no native boolean type. They are always strings, and may be empty or
- unset (which differs from empty.) Furthermore, notions of what is "truthy" in shell script
- differ from that of python.
+ Environment variables have no native boolean type. They are always strings,
+ and may be empty or unset (which differs from empty.) Furthermore,
+ notions of what is "truthy" in shell script differ from that of python.
- This function converts environment variables to python boolean True or False in
- case-insensitive, expected ways to avoid pitfalls:
+ This function converts environment variables to python
+ boolean True or False in case-insensitive,
+ expected ways to avoid pitfalls:
"True", "true", and "1" become True
"False", "false", and "0" become False
- unset or empty becomes False by default (toggle with 'default' parameter.)
- any other value becomes True by default (toggle with 'unknown' parameter.)
+ unset or empty becomes False by default
+ (toggle with 'default' parameter.)
+ any other value becomes True by default
+ (toggle with 'unknown' parameter.)
"""
return {
- 'true': True, '1': True, # 't': True,
- 'false': False, '0': False, # 'f': False.
+ 'true': True, '1': True, # 't': True,
+ 'false': False, '0': False, # 'f': False.
'': default,
- }.get(os.getenv(key, '').lower(), unknown)
+ }.get(os.getenv(key, '').lower(), unknown)
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
def handle(self, *args, **options):
name = "Documentation"
- content = "<p>This is the default content of Documentation1 page - you can change it through CMS.</p>"
- page = RichTextPage.objects.get_or_create(title=name, defaults={'content': content, 'login_required': True})
+ content = "<p>This is the default content of Documentation1 page - \
+ you can change it through CMS.</p>"
+ page = RichTextPage.objects.get_or_create(
+ title=name, defaults={'content': content, 'login_required': True})
print("Created Ice page: %s" % page[0].title)
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
from __future__ import unicode_literals
-
from django.db import migrations
-class Migration(migrations.Migration):
- dependencies = [
+class Migration(migrations.Migration):
+ dependencies = [
]
-
operations = [
]
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
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
'''
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)
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),
]
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
from __future__ import unicode_literals
from django.db import migrations
-from mezzanine.blog.models import BlogCategory
-from django.contrib.sites.models import Site
-#This migration file creates default categories
+# This migration file creates default categories
'''
Creating ICE default categories
'''
+
+
def create_categories(apps, schema_editor):
- print("Used to create the categories but now we will create them with command")
+ print("Used to create the categories, \
+ but now we will create them with command")
+
class Migration(migrations.Migration):
-
- dependencies = [ ('cms', '0002_user_application'), ]
+
+ dependencies = [('cms', '0002_user_application'), ]
operations = [
- migrations.RunPython(create_categories),
+ migrations.RunPython(create_categories),
]
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
from __future__ import unicode_literals
from django.db import migrations
-from mezzanine.pages.models import RichTextPage
-from django.contrib.sites.models import Site
# This migration file creates default pages
'''
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
from django.db.models import Q
-from mezzanine.pages.models import Page, RichTextPage
+from mezzanine.pages.models import RichTextPage
from cms.serializers import SearchPageSerializer
@staticmethod
def search(keyword):
- pages = RichTextPage.objects.published().filter(Q(title__icontains=keyword) |
- Q(content__icontains=keyword))
+ pages = RichTextPage.objects.published().filter(
+ Q(title__icontains=keyword) |
+ Q(content__icontains=keyword))
return SearchPageSerializer(pages.values(), many=True).data
+++ /dev/null
-# ============LICENSE_START==========================================
-# org.onap.vvp/cms
-# ===================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ===================================================================
-#
-# Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
-# you may not use this software except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-#
-# Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
-# you may not use this documentation except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://creativecommons.org/licenses/by/4.0/
-#
-# Unless required by applicable law or agreed to in writing, documentation
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# ============LICENSE_END============================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-
-# Settings file for ICE CMS
-#
-# You should arrange to overwrite this file with one containing settings for your environment.
-#
-# In Kubernetes, for example, this means mount a configMap volume to /srv/settings containing
-# settings in the file __init__.py.
--- /dev/null
+# Settings file for VVP CMS
+#
+# You should arrange to overwrite this file,
+# with one containing settings for your environment.
+#
+# In Kubernetes, for example, this means mount a configMap,
+# volume to /srv/settings containing, settings in the file __init__.py.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# REST API URLs
url(r'^api/pages/search/?$', PageSearch.as_view()),
url("^api/", include("mezzanine_api.urls")),
-
# We don't want to presume how your homepage works, so here are a
# few patterns you can use to set it up.
# from it, and use them directly below instead of using
# ``mezzanine.urls``.
url("^", include("mezzanine.urls")),
-
# MOUNTING MEZZANINE UNDER A PREFIX
# ---------------------------------
# You can also mount all of Mezzanine's urlpatterns under a
# of this file as well.
# Note that for any of the various homepage patterns above, you'll
# need to use the ``SITE_PREFIX`` setting as well.
-
# ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls"))
-
-
-
]
-
# Adds ``STATIC_URL`` to the context of error pages, so that error
# pages can use JS, CSS and images.
handler404 = "mezzanine.core.views.page_not_found"
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
env.hosts = conf.get("HOSTS", [""])
env.proj_name = conf.get("PROJECT_NAME", env.proj_app)
-env.venv_home = conf.get("VIRTUALENV_HOME", "/home/%s/.virtualenvs" % env.user)
+env.venv_home = conf.get(
+ "VIRTUALENV_HOME", "/home/%s/.virtualenvs" % env.user)
env.venv_path = join(env.venv_home, env.proj_name)
env.proj_path = "/home/%s/mezzanine/%s" % (env.user, env.proj_name)
env.manage = "%s/bin/python %s/manage.py" % (env.venv_path, env.proj_path)
and gets new requirements if changes have occurred.
"""
reqs_path = join(env.proj_path, env.reqs_path)
- get_reqs = lambda: run("cat %s" % reqs_path, show=False)
+
+ def get_reqs(): return run("cat %s" % reqs_path, show=False)
old_reqs = get_reqs() if env.reqs_path else ""
yield
if old_reqs:
if "%(db_pass)s" in local_data:
env.db_pass = db_pass()
local_data %= env
- clean = lambda s: s.replace("\n", "").replace("\r", "").strip()
+
+ def clean(s): return s.replace("\n", "").replace("\r", "").strip()
if clean(remote_data) == clean(local_data):
return
upload_template(local_path, remote_path, env, use_sudo=True, backup=False)
if env.deploy_tool in env.vcs_tools:
with cd(env.repo_path):
if env.deploy_tool == "git":
- run("git rev-parse HEAD > %s/last.commit" % env.proj_path)
+ run("git rev-parse HEAD > %s/last.commit" % env.proj_path)
elif env.deploy_tool == "hg":
- run("hg id -i > last.commit")
+ run("hg id -i > last.commit")
with project():
static_dir = static()
if exists(static_dir):
if env.deploy_tool in env.vcs_tools:
with cd(env.repo_path):
if env.deploy_tool == "git":
- run("GIT_WORK_TREE={0} git checkout -f "
- "`cat {0}/last.commit`".format(env.proj_path))
+ run("GIT_WORK_TREE={0} git checkout -f "
+ "`cat {0}/last.commit`".format(env.proj_path))
elif env.deploy_tool == "hg":
- run("hg update -C `cat last.commit`")
+ run("hg update -C `cat last.commit`")
with project():
with cd(join(static(), "..")):
run("tar -xf %s/static.tar" % env.proj_path)
-#!/usr/bin/env python
# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings")
-
from django.core.management import execute_from_command_line
-
execute_from_command_line(sys.argv)