-
-
Save cosbgn/4a151e95064d38eb07df82ea0220c36f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) | |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
#### Private Settings #### | |
# Django | |
SECRET_KEY = '3tjk!g=7a(5(SOMETHINGsjf#-wd' | |
# Google oAuth for Analytic.me | |
GOOGLE_OAUTH2_CLIENT_ID = '2620643MY ID.com' | |
GOOGLE_OAUTH2_CLIENT_SECRET = 'Ra04MY SECRETaaq-H' | |
OAUTH_REDIRECT_URI = 'http://localhost:8000/gconnect/' | |
##### END Private Settings ##### | |
INSTALLED_APPS = [ | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'apps.authentication', # For Authentication | |
'apps.ga_app', # For GA Reports | |
# 'registration', # For User Registration Redux | |
'rest_framework', | |
'django_filters', # To filter date ranges in the Rest Framework | |
] | |
MIDDLEWARE = [ | |
'django.middleware.security.SecurityMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
] | |
ROOT_URLCONF = 'myapp.urls' | |
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': [os.path.join(BASE_DIR,'frontend')], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
'django.template.context_processors.debug', | |
'django.template.context_processors.request', | |
'django.contrib.auth.context_processors.auth', | |
'django.contrib.messages.context_processors.messages', | |
], | |
}, | |
}, | |
] | |
WSGI_APPLICATION = 'myapp.wsgi.application' | |
AUTH_PASSWORD_VALIDATORS = [ | |
{ | |
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | |
}, | |
] | |
# Internationalization | |
# https://docs.djangoproject.com/en/1.11/topics/i18n/ | |
LANGUAGE_CODE = 'en-us' | |
TIME_ZONE = 'UTC' | |
USE_I18N = True | |
USE_L10N = True | |
USE_TZ = True | |
## Registration Settings ## | |
REGISTRATION_OPEN = True # If True, users can register | |
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value. | |
REGISTRATION_AUTO_LOGIN = True # If True, the user will be automatically logged in. | |
#LOGIN_URL = '/accounts/login/?error=loginrequired' # The page users are directed to if they are not logged in, | |
# and are trying to access pages requiring authentication | |
LOGIN_URL = '/start' | |
REGISTRATION_EMAIL_HTML = False | |
#### Google oAuth ##### | |
GOOGLE_SCOPE = ('email', # email --> saved as username | |
'profile', # to get users's first name, good for emailing them. Probably we can also get the email form here..? | |
'https://www.googleapis.com/auth/analytics.edit', # Manage Entities, i.e. Get Properties | |
'https://www.googleapis.com/auth/analytics', # View GA Data | |
) | |
GOOGLE_OAUTH2_STORAGE_MODEL = { | |
'model': 'ga.models.CredentialsModel', | |
'user_property': 'user_id', | |
'credentials_property': 'credential', | |
} | |
# Rest Framework | |
REST_FRAMEWORK = { | |
'DEFAULT_AUTHENTICATION_CLASSES':( | |
'rest_framework.authentication.SessionAuthentication', | |
), | |
'DEFAULT_PERMISSION_CLASSES': ( | |
'rest_framework.permissions.IsAuthenticated', | |
), | |
'DEFAULT_FILTER_BACKENDS': ( | |
'django_filters.rest_framework.DjangoFilterBackend', | |
), | |
} | |
#### Test Prod. Settings #### | |
try: | |
from .local_settings import * | |
print('Local Settings Loaded') | |
except ImportError: | |
print('Production Settings Loaded') | |
DEBUG = True | |
# oAuth redirect URI ~ | |
OAUTH_REDIRECT_URI = 'http://dev.myapp.me/gconnect' | |
LOGIN_REDIRECT_URL = '/report/' # The page you want users to arrive at after they successful log in | |
ALLOWED_HOSTS = [ | |
'dev-myapp-me.us-west-1.elasticbeanstalk.com', | |
] | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'NAME': os.environ['RDS_DB_NAME'], | |
'USER': os.environ['RDS_USERNAME'], | |
'PASSWORD': os.environ['RDS_PASSWORD'], | |
'HOST': os.environ['RDS_HOSTNAME'], | |
'PORT': os.environ['RDS_PORT'], | |
} | |
} | |
# STATIC_ROOT = os.path.join(BASE_DIR, "static") | |
# # STATIC_ROOT = 'static' | |
# STATIC_URL = '/static/' | |
STATIC_ROOT = os.path.join(BASE_DIR, "www", "static") | |
STATIC_URL = '/static/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment