Fakultas Ilmu Komputer UI

Commit cbe7e796 authored by I Gusti Putu Agastya Indrayana's avatar I Gusti Putu Agastya Indrayana
Browse files

Hotfix staging persistent storage

parent 970abaeb
......@@ -15,6 +15,7 @@ import os
import dj_database_url
import django_heroku
from decouple import config
from google.oauth2 import service_account
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......@@ -99,9 +100,11 @@ if is_local:
elif is_heroku:
DATABASES = {}
database_url = os.getenv("DATABASE_URL")
DATABASES["default"] = dj_database_url.parse(database_url, conn_max_age=600)
DATABASES["default"] = dj_database_url.parse(
database_url, conn_max_age=600)
else:
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": os.path.join(BASE_DIR, "db.sqlite3"),}}
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"), }}
STATICFILES_DIRS = (os.path.join(BASE_DIR, "staticfiles"),)
......@@ -111,10 +114,10 @@ STATICFILES_DIRS = (os.path.join(BASE_DIR, "staticfiles"),)
AUTH_USER_MODEL = "authentication.User"
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",},
{"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", },
]
......@@ -146,5 +149,26 @@ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"
if is_heroku:
service_account_info = {
"type": "service_account",
"project_id": config("project_id"),
"private_key_id": config("private_key_id"),
"private_key": config("private_key"),
"client_email": config("client_email"),
"client_id": config("client_id"),
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/788875616341-compute%40developer.gserviceaccount.com"
}
GS_CREDENTIALS = service_account.Credentials.from_service_account_info(
service_account_info)
DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
GS_BUCKET_NAME = "digipus-gitlab-persistent-storage"
GS_DEFAULT_ACL = 'publicRead'
STATICFILES_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
MEDIA_URL = 'https://storage.googleapis.com/{}/'.format(GS_BUCKET_NAME)
MEDIA_ROOT = 'https://storage.googleapis.com/{}/'.format(GS_BUCKET_NAME)
LOGOUT_REDIRECT_URL = "/"
......@@ -4,8 +4,13 @@ astroid==2.3.3
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.5
beautifulsoup4==4.9.0
black==19.10b0
bs4==0.0.1
cachetools==4.1.0
certifi==2020.4.5.1
cfgv==3.1.0
chardet==3.0.4
click==7.1.1
colorama==0.4.3
coverage==5.0.4
......@@ -13,9 +18,20 @@ distlib==0.3.0
dj-database-url==0.5.0
Django==3.0.3
django-heroku==0.3.1
django-storages==1.9.1
entrypoints==0.3
filelock==3.0.12
flake8==3.7.9
flake8-isort==3.0.0
google-api-core==1.17.0
google-auth==1.14.1
google-cloud-core==1.3.0
google-cloud-storage==1.28.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
gunicorn==20.0.4
identify==1.4.15
idna==2.9
importlib-metadata==1.5.2
importlib-resources==1.4.0
isort==4.3.21
......@@ -28,9 +44,13 @@ pathspec==0.8.0
Pillow==7.1.1
pluggy==0.13.1
pre-commit==2.3.0
protobuf==3.11.3
psycopg2==2.8.4
py==1.8.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.5.0
pyflakes==2.1.1
pylint==2.4.4
pylint-django==2.0.15
pylint-plugin-utils==0.6
......@@ -41,10 +61,15 @@ python-decouple==3.3
pytz==2019.3
PyYAML==5.3.1
regex==2020.4.4
requests==2.23.0
rsa==4.0
six==1.14.0
soupsieve==2.0
sqlparse==0.3.1
testfixtures==6.14.1
toml==0.10.0
typed-ast==1.4.1
urllib3==1.25.9
virtualenv==20.0.18
wcwidth==0.1.9
whitenoise==5.0.1
......
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