Commit 6eb50501 authored by sim's avatar sim

[CONF] Move django secrets and local settings in gargantext.ini

parent 24cd6f49
...@@ -20,6 +20,7 @@ SQLAlchemy-Utils = "*" ...@@ -20,6 +20,7 @@ SQLAlchemy-Utils = "*"
django-celery = "*" django-celery = "*"
djangorestframework = "*" djangorestframework = "*"
djangorestframework-jwt = "*" djangorestframework-jwt = "*"
python-decouple = "*"
[requires] [requires]
......
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "812bbbd579361fcd66f99a5fe8a453e712b008fcabd276b4cc803c955a3fc14c" "sha256": "53e18b75e4a0cfdcafd2ff47bd1d6772a5638f975b59fe95f4575e4086f60346"
}, },
"host-environment-markers": { "host-environment-markers": {
"implementation_name": "cpython", "implementation_name": "cpython",
...@@ -160,6 +160,12 @@ ...@@ -160,6 +160,12 @@
], ],
"version": "==2.6.1" "version": "==2.6.1"
}, },
"python-decouple": {
"hashes": [
"sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d"
],
"version": "==3.1"
},
"pytz": { "pytz": {
"hashes": [ "hashes": [
"sha256:80af0f3008046b9975242012a985f04c5df1f01eed4ec1633d56cc47a75a6a48", "sha256:80af0f3008046b9975242012a985f04c5df1f01eed4ec1633d56cc47a75a6a48",
......
# django.ini file [django]
[uwsgi]
DEBUG = True
SECRET_KEY = !%ktkh981)piil1%t5r0g4$^0=uvdafk!=f2x8djxy7_gq(n5%
DB_PASS = C8kdcUrAQy66U
[uwsgi]
env = DJANGO_SETTINGS_MODULE=gargantext.settings env = DJANGO_SETTINGS_MODULE=gargantext.settings
#module = django.core.handlers.wsgi:WSGIHandler() #module = django.core.handlers.wsgi:WSGIHandler()
......
...@@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ ...@@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
from gargantext.util.config import config
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -20,13 +22,13 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ...@@ -20,13 +22,13 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!%ktkh981)piil1%t5r0g4$^0=uvdafk!=f2x8djxy7_gq(n5%' SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = config('DEBUG', default=False, cast=bool)
MAINTENANCE = False MAINTENANCE = config('MAINTENANCE', default=False, cast=bool)
ALLOWED_HOSTS = [] ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='', cast=lambda v: list(filter(None, v.split(' '))))
# Application definition # Application definition
...@@ -79,11 +81,11 @@ WSGI_APPLICATION = 'gargantext.wsgi.application' ...@@ -79,11 +81,11 @@ WSGI_APPLICATION = 'gargantext.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'gargandb', 'NAME': config('DB_NAME', default='gargandb'),
'USER': 'gargantua', 'USER': config('DB_USER', default='gargantua'),
'PASSWORD': 'C8kdcUrAQy66U', 'PASSWORD': config('DB_PASS'),
'HOST': '127.0.0.1', 'HOST': config('DB_HOST', default='127.0.0.1'),
'PORT': '5432', 'PORT': config('DB_PORT', default='5432'),
'TEST': { 'TEST': {
'NAME': 'test_gargandb', 'NAME': 'test_gargandb',
}, },
...@@ -193,4 +195,4 @@ API_TOKENS = { ...@@ -193,4 +195,4 @@ API_TOKENS = {
# BOOL Interpreter # BOOL Interpreter
BOOL_TOOLS_PATH="/srv/gargantext/gargantext/util/crawlers/sparql" BOOL_TOOLS_PATH = "gargantext/util/crawlers/sparql"
from configparser import RawConfigParser
from decouple import AutoConfig, RepositoryIni
class GargantextIni(RepositoryIni):
SECTION = 'django'
def __init__(self, source):
self.parser = RawConfigParser()
with open(source) as file_:
self.parser.readfp(file_)
class GargantextConfig(AutoConfig):
SUPPORTED = {'gargantext.ini': GargantextIni}
config = GargantextConfig(search_path='.')
Markdown is supported
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