From c8c1f088690b83b21c62d9f0e8a9184568727fae Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Tue, 13 Nov 2018 19:47:43 -0800 Subject: [PATCH] cleanup --- mpcontribs/rest/views.py | 8 +++----- test_site/settings.py | 36 +++++++++++++----------------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/mpcontribs/rest/views.py b/mpcontribs/rest/views.py index 0c115b3a75..9e954f1fcf 100644 --- a/mpcontribs/rest/views.py +++ b/mpcontribs/rest/views.py @@ -4,13 +4,12 @@ from __future__ import unicode_literals import os from bson.json_util import loads +from bson.objectid import ObjectId from django.core.exceptions import PermissionDenied from django.contrib.auth.models import Group +from django.shortcuts import redirect from webtzite.connector import ConnectorBase -from bson.objectid import ObjectId from webtzite import mapi_func, in_docker -from django.shortcuts import redirect -from test_site.settings import PROXY_URL_PREFIX class Connector(ConnectorBase): def connect(self, **kwargs): @@ -29,13 +28,12 @@ def connect(self, **kwargs): def get_endpoint(request): from django.core.urlresolvers import reverse url = reverse('mpcontribs_rest_index')[:-1] - if os.environ.get('JPY_USER') is None and in_docker(): - return 'http://app:5000' + url return request.build_absolute_uri(url) def index(request): jpy_user = os.environ.get('JPY_USER') if jpy_user: + from test_site.settings import PROXY_URL_PREFIX from mpcontribs.rest.make_apidoc_json import make_apidoc_json from subprocess import call make_apidoc_json(get_endpoint(request)) diff --git a/test_site/settings.py b/test_site/settings.py index 5902e1ab44..9490309eeb 100644 --- a/test_site/settings.py +++ b/test_site/settings.py @@ -26,26 +26,20 @@ SECRET_KEY = get_random_secret_key() # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +NODE_ENV = os.environ.get('NODE_ENV', 'production') +DEBUG = True #bool(NODE_ENV == 'development') ALLOWED_HOSTS = ['portal.mpcontribs.org', 'contribs.materialsproject.org', 'localhost'] AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', - #'django_cas_ng.backends.CASBackend', 'webtzite.backends.CASBackend', - #'webtzite.backends.CustomModelBackend', - ##'webtzite.backends.CustomBrowserIDBackend', - #'nopassword.backends.email.EmailBackend' ) -# Application definition - from mpcontribs.users_modules import get_user_installed_apps INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', - #'django_browserid', 'nopassword', 'django.contrib.contenttypes', 'django.contrib.sessions', @@ -60,9 +54,11 @@ 'mpcontribs.explorer', 'zappa_django_utils', 'webpack_loader', + #'corsheaders', ] + get_user_installed_apps() MIDDLEWARE_CLASSES = ( + #'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -95,10 +91,6 @@ WSGI_APPLICATION = 'test_site.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/1.8/ref/settings/#databases - DATABASES = { 'default': { 'ENGINE': 'zappa_django_utils.db.backends.s3sqlite', @@ -108,23 +100,12 @@ } -# Internationalization -# https://docs.djangoproject.com/en/1.8/topics/i18n/ - LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'UTC' - USE_I18N = True - USE_L10N = True - USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.8/howto/static-files/ - JPY_USER = os.environ.get('JPY_USER') PROXY_URL_PREFIX = '/flaskproxy/{}'.format(JPY_USER) if JPY_USER else '' STATIC_URL = PROXY_URL_PREFIX + '/static/' @@ -148,3 +129,12 @@ CAS_RETRY_LOGIN = True CAS_USERNAME_ATTRIBUTE = 'username' CAS_APPLY_ATTRIBUTES_TO_USER = True + +#CORS_ORIGIN_ALLOW_ALL = True +#CORS_ALLOW_CREDENTIALS = True +#CSRF_TRUSTED_ORIGINS = ( 'localhost',) +#CORS_ORIGIN_WHITELIST = ( +# 'contribs.materialsproject.org', +# 'portal.mpcontribs.org', +# 'localhost:8080', +#)