Fakultas Ilmu Komputer UI

Commit 9860244d authored by Azhar Difa Arnanda's avatar Azhar Difa Arnanda
Browse files

Update settings

parent 2c083b46
__pycache__/
.python-version
.coveragerc
.local_env_var.sh
.env_var
static
\ No newline at end of file
......@@ -9,9 +9,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fil
SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = True
DEBUG = os.environ.get('DEBUG', True) != 'False'
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
ALLOWED_HOSTS = [os.environ['ALLOWED_HOST'], 'localhost']
# Application definition
......@@ -67,8 +67,12 @@ WSGI_APPLICATION = 'home_industry.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['DATABASE_NAME'],
'USER': os.environ['DATABASE_USER'],
'PASSWORD': os.environ['DATABASE_PASSWORD'],
'HOST': os.environ['DATABASE_HOST'],
'PORT': os.environ['DATABASE_PORT'],
},
}
......
......@@ -11,7 +11,7 @@ SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = os.environ.get('DEBUG', True) != 'False'
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '10.0.2.2']
ALLOWED_HOSTS = [os.environ['ALLOWED_HOST'], 'localhost']
# Application definition
......
import os
from corsheaders import defaults
from rest_framework import settings
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
......@@ -12,7 +11,7 @@ SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = False
ALLOWED_HOSTS = ['api.industripilar.com']
ALLOWED_HOSTS = [os.environ['ALLOWED_HOST'], 'localhost']
# Application definition
......@@ -115,8 +114,12 @@ LOCALE_PATHS = [
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
# Authentication
......@@ -124,17 +127,6 @@ STATIC_URL = '/static/'
AUTH_USER_MODEL = 'api.User'
# Security
# https://docs.djangoproject.com/en/3.0/topics/security/
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
# Django REST framework
# https://www.django-rest-framework.org
......@@ -145,36 +137,20 @@ REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
# Amazon Web Services
AWS = {
'AWS_ACCESS_KEY_ID': os.environ['AWS_ACCESS_KEY_ID'],
'AWS_SECRET_ACCESS_KEY': os.environ['AWS_SECRET_ACCESS_KEY'],
'AWS_REGION_NAME': os.environ['AWS_REGION_NAME'],
}
# Home Industry Admin Site
HOME_INDUSTRY_ADMIN_SITE = {
'URL': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_URL', ''),
'USER_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_USER_PATH', ''),
'PRODUCT_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH', ''),
'TRANSACTION_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH', ''),
'PROGRAM_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH', ''),
'PROGRAM_DONATION_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH', ''),
'URL': 'https://example.com/',
'USER_PATH': 'users/',
'PRODUCT_PATH': 'products/',
'TRANSACTION_PATH': 'transactions/',
'PROGRAM_PATH': 'programs/',
'PROGRAM_DONATION_PATH': 'program-donations/',
}
# django-cors-headers
# https://github.com/adamchainz/django-cors-headers
CORS_ALLOW_HEADERS = list(defaults.default_headers) + [
'Access-Control-Expose-Headers',
]
CORS_EXPOSE_HEADERS = [
'Content-Disposition',
]
CORS_ORIGIN_ALLOW_ALL = True
# django-rest-knox
......@@ -189,28 +165,3 @@ REST_KNOX = {
'AUTO_REFRESH': False,
'EXPIRY_DATETIME_FORMAT': settings.api_settings.DATETIME_FORMAT,
}
# django-storages
# https://github.com/jschneier/django-storages
DEFAULT_FILE_STORAGE = 'home_industry.storages.MediaStorage'
STATICFILES_STORAGE = 'home_industry.storages.StaticStorage'
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
AWS_STORAGE_BUCKET_NAME = os.environ['AWS_STORAGE_BUCKET_NAME']
AWS_DEFAULT_ACL = None
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_QUERYSTRING_AUTH = False
MEDIA_LOCATION = 'media'
STATIC_LOCATION = 'static'
import os
import dj_database_url
from corsheaders import defaults
from rest_framework import settings
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
......@@ -13,7 +11,7 @@ SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = os.environ.get('DEBUG', True) != 'False'
ALLOWED_HOSTS = ['.herokuapp.com']
ALLOWED_HOSTS = [os.environ['ALLOWED_HOST'], 'localhost']
# Application definition
......@@ -68,7 +66,14 @@ WSGI_APPLICATION = 'home_industry.wsgi.application'
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': dj_database_url.config(conn_max_age=600, ssl_require=True),
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['DATABASE_NAME'],
'USER': os.environ['DATABASE_USER'],
'PASSWORD': os.environ['DATABASE_PASSWORD'],
'HOST': os.environ['DATABASE_HOST'],
'PORT': os.environ['DATABASE_PORT'],
},
}
# Password validation
......@@ -109,8 +114,12 @@ LOCALE_PATHS = [
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
# Authentication
......@@ -118,17 +127,6 @@ STATIC_URL = '/static/'
AUTH_USER_MODEL = 'api.User'
# Security
# https://docs.djangoproject.com/en/3.0/topics/security/
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
# Django REST framework
# https://www.django-rest-framework.org
......@@ -139,36 +137,20 @@ REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
# Amazon Web Services
AWS = {
'AWS_ACCESS_KEY_ID': os.environ['AWS_ACCESS_KEY_ID'],
'AWS_SECRET_ACCESS_KEY': os.environ['AWS_SECRET_ACCESS_KEY'],
'AWS_REGION_NAME': os.environ['AWS_REGION_NAME'],
}
# Home Industry Admin Site
HOME_INDUSTRY_ADMIN_SITE = {
'URL': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_URL', ''),
'USER_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_USER_PATH', ''),
'PRODUCT_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH', ''),
'TRANSACTION_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH', ''),
'PROGRAM_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH', ''),
'PROGRAM_DONATION_PATH': os.environ.get('HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH', ''),
'URL': 'https://example.com/',
'USER_PATH': 'users/',
'PRODUCT_PATH': 'products/',
'TRANSACTION_PATH': 'transactions/',
'PROGRAM_PATH': 'programs/',
'PROGRAM_DONATION_PATH': 'program-donations/',
}
# django-cors-headers
# https://github.com/adamchainz/django-cors-headers
CORS_ALLOW_HEADERS = list(defaults.default_headers) + [
'Access-Control-Expose-Headers',
]
CORS_EXPOSE_HEADERS = [
'Content-Disposition',
]
CORS_ORIGIN_ALLOW_ALL = True
# django-rest-knox
......@@ -183,28 +165,3 @@ REST_KNOX = {
'AUTO_REFRESH': False,
'EXPIRY_DATETIME_FORMAT': settings.api_settings.DATETIME_FORMAT,
}
# django-storages
# https://github.com/jschneier/django-storages
DEFAULT_FILE_STORAGE = 'home_industry.storages.MediaStorage'
STATICFILES_STORAGE = 'home_industry.storages.StaticStorage'
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
AWS_STORAGE_BUCKET_NAME = os.environ['AWS_STORAGE_BUCKET_NAME']
AWS_DEFAULT_ACL = None
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_QUERYSTRING_AUTH = False
MEDIA_LOCATION = 'media'
STATIC_LOCATION = 'static'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment