diff --git a/Dockerfile b/Dockerfile index 3696141..7dd746c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.7 ENV PYTHONUNBUFFERED 1 -ENV DJANGO_SETTINGS_MODULE uwpath_backend.settings +ENV DJANGO_SETTINGS_MODULE uwpath_backend.local WORKDIR /opt/oracle RUN apt-get update && \ apt-get install -y libaio1 unzip wget @@ -15,7 +15,6 @@ RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantcli RUN mkdir /code WORKDIR /code COPY requirements.txt /code/ -RUN pip install psycopg2-binary==2.8.6 RUN pip install -r requirements.txt COPY . /code/ ENV PATH /code/:$PATH diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..a2222d0 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,10 @@ +FROM python:3.7 +ENV PYTHONUNBUFFERED 1 +ENV DJANGO_SETTINGS_MODULE uwpath_backend.dev +RUN mkdir /code +WORKDIR /code +COPY requirements.txt /code/ +RUN pip install -r requirements.txt +COPY . /code/ +ENV PATH /code/:$PATH +EXPOSE $PORT \ No newline at end of file diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 0000000..a140571 --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,10 @@ +FROM python:3.7 +ENV PYTHONUNBUFFERED 1 +ENV DJANGO_SETTINGS_MODULE uwpath_backend.prod +RUN mkdir /code +WORKDIR /code +COPY requirements.txt /code/ +RUN pip install -r requirements.txt +COPY . /code/ +ENV PATH /code/:$PATH +EXPOSE $PORT \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c49c213..37a0c49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: container_name: uwpath_backend build: . command: bash -c " - python manage.py migrate - && python manage.py runserver 0.0.0.0:8000 + python manage.py migrate && + gunicorn uwpath_backend.wsgi --bind 0.0.0.0:$PORT " # volumes: # - ./Wallet_uwpathparallel:/code/Wallet_uwpathparallel @@ -16,11 +16,10 @@ services: - uwpath_db_network - uwpath_backend_network environment: + - DB_HOST=db + - SECRET_KEY=7ldnlu_gz*&vx&=4)q3#74ih@nzx*owgeu^=*katjqpbb-s1sk + - DJANGO_ENV=prod - UWPATH_ENVIRONMENT=docker - # - SECRET_KEY=7ldnlu_gz*&vx&=4)q3#74ih@nzx*owgeu^=*katjqpbb-s1sk - # - DJANGO_SETTINGS_MODULE=uwpath_backend.dev - # - TNS_ADMIN=/code/Wallet_uwpathparallel - networks: uwpath_db_network: external: true diff --git a/manage.py b/manage.py index 177465b..be397b0 100644 --- a/manage.py +++ b/manage.py @@ -5,7 +5,7 @@ def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.settings') + #os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.production') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/requirements.txt b/requirements.txt index deb988e..427e070 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ django-cors-headers==3.3.0 postgres==3.0.0 gunicorn==20.0.4 cx_Oracle == 8.3.0 +psycopg2-binary==2.8.6 \ No newline at end of file diff --git a/uwpath_backend/asgi.py b/uwpath_backend/asgi.py index d3aaa97..35a5018 100644 --- a/uwpath_backend/asgi.py +++ b/uwpath_backend/asgi.py @@ -11,7 +11,7 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.settings') +#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.settings.__init__') application = get_asgi_application() diff --git a/uwpath_backend/dev.py b/uwpath_backend/dev.py new file mode 100644 index 0000000..8ea885c --- /dev/null +++ b/uwpath_backend/dev.py @@ -0,0 +1,183 @@ +""" +Django settings for uwpath_backend project. + +Generated by 'django-admin startproject' using Django 3.0. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + + +import os + + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + + +# HTTPS Settings +#SESSION_COOKIE_SECURE = True +#CSRF_COOKIE_SECURE = True +#SECURE_SSL_REDIRECT = True + +# HSTS Settings +#SECURE_HSTS_SECONDS = 31536000 # 1 year +#SECURE_HSTS_PRELOAD = True +#SECURE_HSTS_INCLUDE_SUBDOMAINS = True + + +#STATIC_URL = '/static/' +#STATIC_ROOT = '/code/static/' + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend', 'parallel.uwpath.com'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'app.apps.UwpathConfig', + 'rest_framework', + 'corsheaders' +] + +MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + '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 = 'uwpath_backend.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + '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 = 'uwpath_backend.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.oracle', + 'NAME': os.getenv("ORACLE_DSN"), + 'USER': os.getenv("DB_USER"), + 'PASSWORD': os.getenv("DB_PASS"), + 'HOST': os.getenv("DB_HOST"), + 'PORT': os.getenv("DB_PORT") + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +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/3.0/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/3.0/howto/static-files/ + +STATIC_URL = '/static/' + + +STATICFILES_DIRS = [ + 'app/static/', +] + + +STATIC_ROOT = os.path.join(BASE_DIR, "static/") + +# Note for emails to work please set up env variables. Note: You might need to restart your computer + +# For sending emails +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +DEFAULT_FROM_EMAIL = os.environ.get('UWPath_Email_Account') +SERVER_EMAIL = os.environ.get('UWPath_Email_Account') +EMAIL_HOST = os.environ.get('UWPath_Host') +EMAIL_PORT = 587 +EMAIL_HOST_USER = os.environ.get('UWPath_Email_Account') +EMAIL_HOST_PASSWORD = os.environ.get('UWPath_Email_Password') +EMAIL_USE_TLS = True + +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) +} + +CORS_ORIGIN_ALLOW_ALL=True + +CORS_ORIGIN_WHITELIST = [ + 'http://localhost:8000', + 'http://localhost:8080', + 'http://127.0.0.1:8000', + 'http://0.0.0.0:8000', + 'http://129.153.61.57', + 'http://parallel.uwpath.com', +] diff --git a/uwpath_backend/local.py b/uwpath_backend/local.py new file mode 100644 index 0000000..beae33a --- /dev/null +++ b/uwpath_backend/local.py @@ -0,0 +1,160 @@ +""" +Django settings for uwpath_backend project. + +Generated by 'django-admin startproject' using Django 3.0. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'app.apps.UwpathConfig', + 'rest_framework', + 'corsheaders' +] + +MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + '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 = 'uwpath_backend.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + '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 = 'uwpath_backend.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.oracle', + 'NAME': os.getenv("ORACLE_DSN"), + 'USER': os.getenv("DB_USER"), + 'PASSWORD': os.getenv("DB_PASS"), + 'HOST': os.getenv("DB_HOST"), + 'PORT': os.getenv("DB_PORT") + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +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/3.0/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/3.0/howto/static-files/ + +STATIC_URL = '/static/' + +STATICFILES_DIRS = [ + 'app/static/', +] + +# Note for emails to work please set up env variables. Note: You might need to restart your computer + +# For sending emails +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +DEFAULT_FROM_EMAIL = os.environ.get('UWPath_Email_Account') +SERVER_EMAIL = os.environ.get('UWPath_Email_Account') +EMAIL_HOST = os.environ.get('UWPath_Host') +EMAIL_PORT = 587 +EMAIL_HOST_USER = os.environ.get('UWPath_Email_Account') +EMAIL_HOST_PASSWORD = os.environ.get('UWPath_Email_Password') +EMAIL_USE_TLS = True + +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) +} + +CORS_ORIGIN_ALLOW_ALL=True + +CORS_ORIGIN_WHITELIST = [ + 'http://localhost:8000', + 'http://localhost:8080', + 'http://127.0.0.1:8000', + 'http://0.0.0.0:8000', +] diff --git a/uwpath_backend/prod.py b/uwpath_backend/prod.py new file mode 100644 index 0000000..06b8386 --- /dev/null +++ b/uwpath_backend/prod.py @@ -0,0 +1,182 @@ +""" +Django settings for uwpath_backend project. + +Generated by 'django-admin startproject' using Django 3.0. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + + +import os + + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + + +# HTTPS Settings +#SESSION_COOKIE_SECURE = True +#CSRF_COOKIE_SECURE = True +#SECURE_SSL_REDIRECT = True + +# HSTS Settings +#SECURE_HSTS_SECONDS = 31536000 # 1 year +#SECURE_HSTS_PRELOAD = True +#SECURE_HSTS_INCLUDE_SUBDOMAINS = True + + +#STATIC_URL = '/static/' +#STATIC_ROOT = '/code/static/' + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend', 'uwpath.com'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'app.apps.UwpathConfig', + 'rest_framework', + 'corsheaders' +] + +MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + '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 = 'uwpath_backend.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + '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 = 'uwpath_backend.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.oracle', + 'NAME': os.getenv("ORACLE_DSN"), + 'USER': os.getenv("DB_USER"), + 'PASSWORD': os.getenv("DB_PASS"), + 'HOST': os.getenv("DB_HOST"), + 'PORT': os.getenv("DB_PORT") + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +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/3.0/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/3.0/howto/static-files/ + +STATIC_URL = '/static/' + + +STATICFILES_DIRS = [ + 'app/static/', +] + + +STATIC_ROOT = os.path.join(BASE_DIR, "static/") + +# Note for emails to work please set up env variables. Note: You might need to restart your computer + +# For sending emails +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +DEFAULT_FROM_EMAIL = os.environ.get('UWPath_Email_Account') +SERVER_EMAIL = os.environ.get('UWPath_Email_Account') +EMAIL_HOST = os.environ.get('UWPath_Host') +EMAIL_PORT = 587 +EMAIL_HOST_USER = os.environ.get('UWPath_Email_Account') +EMAIL_HOST_PASSWORD = os.environ.get('UWPath_Email_Password') +EMAIL_USE_TLS = True + +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) +} + +CORS_ORIGIN_ALLOW_ALL=True + +CORS_ORIGIN_WHITELIST = [ + 'http://localhost:8000', + 'http://localhost:8080', + 'http://127.0.0.1:8000', + 'http://0.0.0.0:8000', +] diff --git a/uwpath_backend/production.py b/uwpath_backend/production.py new file mode 100644 index 0000000..f147225 --- /dev/null +++ b/uwpath_backend/production.py @@ -0,0 +1,182 @@ +""" +Django settings for uwpath_backend project. + +Generated by 'django-admin startproject' using Django 3.0. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + + +import os + + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + + +# HTTPS Settings +#SESSION_COOKIE_SECURE = True +#CSRF_COOKIE_SECURE = True +#SECURE_SSL_REDIRECT = True + +# HSTS Settings +#SECURE_HSTS_SECONDS = 31536000 # 1 year +#SECURE_HSTS_PRELOAD = True +#SECURE_HSTS_INCLUDE_SUBDOMAINS = True + + +#STATIC_URL = '/static/' +#STATIC_ROOT = '/code/static/' + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend', 'uwpath.com'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'app.apps.UwpathConfig', + 'rest_framework', + 'corsheaders' +] + +MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + '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 = 'uwpath_backend.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + '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 = 'uwpath_backend.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'postgres' if os.getenv("DB_NAME") is None else os.getenv("DB_NAME"), + 'USER': 'postgres' if os.getenv("DB_USER") is None else os.getenv("DB_USER"), + 'PASSWORD': '1234' if os.getenv("DB_PASS") is None else os.getenv("DB_PASS"), + 'HOST': 'db' if os.getenv("DB_HOST") is None else os.getenv("DB_HOST"), + 'PORT': '5432' if os.getenv("DB_PORT") is None else os.getenv("DB_PORT"), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +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/3.0/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/3.0/howto/static-files/ + +STATIC_URL = '/static/' + + +STATICFILES_DIRS = [ + 'app/static/', +] + + +STATIC_ROOT = os.path.join(BASE_DIR, "static/") + +# Note for emails to work please set up env variables. Note: You might need to restart your computer + +# For sending emails +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +DEFAULT_FROM_EMAIL = os.environ.get('UWPath_Email_Account') +SERVER_EMAIL = os.environ.get('UWPath_Email_Account') +EMAIL_HOST = os.environ.get('UWPath_Host') +EMAIL_PORT = 587 +EMAIL_HOST_USER = os.environ.get('UWPath_Email_Account') +EMAIL_HOST_PASSWORD = os.environ.get('UWPath_Email_Password') +EMAIL_USE_TLS = True + +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) +} + +CORS_ORIGIN_ALLOW_ALL=True + +CORS_ORIGIN_WHITELIST = [ + 'http://localhost:8000', + 'http://localhost:8080', + 'http://127.0.0.1:8000', + 'http://0.0.0.0:8000', +] diff --git a/uwpath_backend/settings.py b/uwpath_backend/settings.py index 3f5a99e..9c0ffd3 100644 --- a/uwpath_backend/settings.py +++ b/uwpath_backend/settings.py @@ -1,11 +1,8 @@ """ Django settings for uwpath_backend project. - Generated by 'django-admin startproject' using Django 3.0. - For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ - For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ @@ -21,10 +18,8 @@ # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '7ldnlu_gz*&vx&=4)q3#74ih@nzx*owgeu^=*katjqpbb-s1sk' +SECRET_KEY = os.getenv("SECRET_KEY") -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend'] @@ -157,4 +152,4 @@ 'http://localhost:8080', 'http://127.0.0.1:8000', 'http://0.0.0.0:8000', -] +] \ No newline at end of file diff --git a/uwpath_backend/wsgi.py b/uwpath_backend/wsgi.py index 4c31f8e..5fce3b9 100644 --- a/uwpath_backend/wsgi.py +++ b/uwpath_backend/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.settings') +#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uwpath_backend.production') application = get_wsgi_application()