Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Nov 14, 2018
1 parent 9725819 commit c8c1f08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
8 changes: 3 additions & 5 deletions mpcontribs/rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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))
Expand Down
36 changes: 13 additions & 23 deletions test_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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/'
Expand All @@ -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',
#)

0 comments on commit c8c1f08

Please sign in to comment.