diff options
34 files changed, 132 insertions, 125 deletions
diff --git a/Dockerfile b/Dockerfile index 5017392..5017392 100755..100644 --- a/Dockerfile +++ b/Dockerfile diff --git a/LICENSE.TXT b/LICENSE.TXT index 52ff78f..52ff78f 100755..100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT diff --git a/LICENSE.uWSGI b/LICENSE.uWSGI index ff68963..ff68963 100755..100644 --- a/LICENSE.uWSGI +++ b/LICENSE.uWSGI diff --git a/README.md b/README.md index d5cb843..d5cb843 100755..100644 --- a/README.md +++ b/README.md diff --git a/django/README.md b/django/README.md index d5cb843..4ac73ed 100755..100644 --- a/django/README.md +++ b/django/README.md @@ -1 +1,39 @@ +# ============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 + diff --git a/django/cms/__init__.py b/django/cms/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/__init__.py +++ b/django/cms/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/envbool.py b/django/cms/envbool.py index 72994d8..df9dd29 100755..100644 --- a/django/cms/envbool.py +++ b/django/cms/envbool.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -37,24 +37,28 @@ # 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) diff --git a/django/cms/management/__init__.py b/django/cms/management/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/management/__init__.py +++ b/django/cms/management/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/management/commands/__init__.py b/django/cms/management/commands/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/management/commands/__init__.py +++ b/django/cms/management/commands/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/management/commands/import_categories.py b/django/cms/management/commands/import_categories.py index 5fc9b9d..d944089 100755..100644 --- a/django/cms/management/commands/import_categories.py +++ b/django/cms/management/commands/import_categories.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/management/commands/import_pages.py b/django/cms/management/commands/import_pages.py index c1fe799..8d915a8 100755..100644 --- a/django/cms/management/commands/import_pages.py +++ b/django/cms/management/commands/import_pages.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -46,6 +46,8 @@ class Command(BaseCommand): 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) diff --git a/django/cms/migrations/0001_initial.py b/django/cms/migrations/0001_initial.py index ba1bcb9..24dd2e9 100755..100644 --- a/django/cms/migrations/0001_initial.py +++ b/django/cms/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -36,13 +36,11 @@ # # 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 = [ ] 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), ] diff --git a/django/cms/migrations/0003_categories.py b/django/cms/migrations/0003_categories.py index 386a1f9..305d33d 100755..100644 --- a/django/cms/migrations/0003_categories.py +++ b/django/cms/migrations/0003_categories.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -37,20 +37,22 @@ # 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), ] diff --git a/django/cms/migrations/0004_pages.py b/django/cms/migrations/0004_pages.py index f064f00..f32466e 100755..100644 --- a/django/cms/migrations/0004_pages.py +++ b/django/cms/migrations/0004_pages.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -37,8 +37,6 @@ # 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 ''' diff --git a/django/cms/migrations/__init__.py b/django/cms/migrations/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/migrations/__init__.py +++ b/django/cms/migrations/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/serializers.py b/django/cms/serializers.py index 6520998..1bd9530 100755..100644 --- a/django/cms/serializers.py +++ b/django/cms/serializers.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/services/__init__.py b/django/cms/services/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/services/__init__.py +++ b/django/cms/services/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/services/page_service.py b/django/cms/services/page_service.py index 36e3269..63bd6e6 100755..100644 --- a/django/cms/services/page_service.py +++ b/django/cms/services/page_service.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -36,7 +36,7 @@ # # 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 @@ -47,7 +47,8 @@ class PageService: @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 diff --git a/django/cms/settings/__init__.py b/django/cms/settings/__init__.py index a53c7b3..df52f04 100755..120000 --- a/django/cms/settings/__init__.py +++ b/django/cms/settings/__init__.py @@ -1,44 +1,7 @@ -# ============LICENSE_START========================================== -# org.onap.vvp/cms -# =================================================================== -# Copyright © 2017 AT&T Intellectual Property. All rights reserved. -# =================================================================== +# Settings file for VVP CMS # -# 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 +# You should arrange to overwrite this file, +# with one containing settings for your environment. # -# 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. +# In Kubernetes, for example, this means mount a configMap, +# volume to /srv/settings containing, settings in the file __init__.py. diff --git a/django/cms/urls.py b/django/cms/urls.py index 97f9d63..06e1d7d 100755..100644 --- a/django/cms/urls.py +++ b/django/cms/urls.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -68,7 +68,6 @@ urlpatterns += [ # 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. @@ -120,7 +119,6 @@ urlpatterns += [ # 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 @@ -134,13 +132,8 @@ urlpatterns += [ # 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" diff --git a/django/cms/views/__init__.py b/django/cms/views/__init__.py index d01d0f0..110a1dc 100755..100644 --- a/django/cms/views/__init__.py +++ b/django/cms/views/__init__.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/views/pages.py b/django/cms/views/pages.py index 987cfec..ea28f93 100755..100644 --- a/django/cms/views/pages.py +++ b/django/cms/views/pages.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/cms/wsgi.py b/django/cms/wsgi.py index 11ea1f9..eb2c15c 100755..100644 --- a/django/cms/wsgi.py +++ b/django/cms/wsgi.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. diff --git a/django/deploy/crontab.template b/django/deploy/crontab.template index dc11b0d..dc11b0d 100755..100644 --- a/django/deploy/crontab.template +++ b/django/deploy/crontab.template diff --git a/django/deploy/gunicorn.conf.py.template b/django/deploy/gunicorn.conf.py.template index 20e4b46..20e4b46 100755..100644 --- a/django/deploy/gunicorn.conf.py.template +++ b/django/deploy/gunicorn.conf.py.template diff --git a/django/deploy/local_settings.py.template b/django/deploy/local_settings.py.template index 217fd2b..217fd2b 100755..100644 --- a/django/deploy/local_settings.py.template +++ b/django/deploy/local_settings.py.template diff --git a/django/deploy/nginx.conf.template b/django/deploy/nginx.conf.template index 7e35a7c..7e35a7c 100755..100644 --- a/django/deploy/nginx.conf.template +++ b/django/deploy/nginx.conf.template diff --git a/django/deploy/supervisor.conf.template b/django/deploy/supervisor.conf.template index a2d0960..a2d0960 100755..100644 --- a/django/deploy/supervisor.conf.template +++ b/django/deploy/supervisor.conf.template diff --git a/django/fabfile.py b/django/fabfile.py index 8dd73c8..b0bfb0e 100755..100644 --- a/django/fabfile.py +++ b/django/fabfile.py @@ -1,4 +1,4 @@ -# ============LICENSE_START========================================== +# ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -87,7 +87,8 @@ env.key_filename = conf.get("SSH_KEY_PATH", None) 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) @@ -180,7 +181,8 @@ def update_changed_requirements(): 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: @@ -284,7 +286,8 @@ def upload_template_and_reload(name): 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) @@ -650,9 +653,9 @@ def deploy(): 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): @@ -693,10 +696,10 @@ def rollback(): 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) diff --git a/django/manage.py b/django/manage.py index fcf5aa7..64b4ec8 100755..100644 --- a/django/manage.py +++ b/django/manage.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # ============LICENSE_START========================================== # org.onap.vvp/cms # =================================================================== @@ -41,7 +40,5 @@ import sys 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) diff --git a/django/requirements.txt b/django/requirements.txt index 8a00ac1..8a00ac1 100755..100644 --- a/django/requirements.txt +++ b/django/requirements.txt |