|
|
@@ -1,111 +0,0 @@ |
|
|
|
import os |
|
|
|
from smartconfigparser import Config |
|
|
|
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|
|
|
|
|
|
|
CONFIG_PATH = os.path.join(BASE_DIR, 'config') |
|
|
|
if not os.path.exists(CONFIG_PATH): |
|
|
|
os.makedirs(CONFIG_PATH) |
|
|
|
|
|
|
|
CONFIG_FILE = os.path.join(CONFIG_PATH, 'config.ini') |
|
|
|
config = Config() |
|
|
|
config.read(CONFIG_FILE) |
|
|
|
|
|
|
|
try: |
|
|
|
SECRET_KEY = config.get('DJANGO', 'SECRET_KEY') |
|
|
|
except: |
|
|
|
print('SECRET_KEY not found! Generating a new one...') |
|
|
|
import random |
|
|
|
|
|
|
|
SECRET_KEY = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$^&*(-_=+)") for i in range(50)]) |
|
|
|
if not config.has_section('DJANGO'): |
|
|
|
config.add_section('DJANGO') |
|
|
|
config.set('DJANGO', 'SECRET_KEY', SECRET_KEY) |
|
|
|
with open(CONFIG_FILE, 'wt') as f: |
|
|
|
config.write(f) |
|
|
|
|
|
|
|
DEBUG = config.getboolean('DJANGO', 'DEBUG', False) |
|
|
|
|
|
|
|
ALLOWED_HOSTS = config.getlist('DJANGO', 'ALLOWED_HOSTS', ['localhost', '127.0.0.1', '*.oslab.fr']) |
|
|
|
|
|
|
|
INSTALLED_APPS = [ |
|
|
|
'api.apps.ApiConfig', |
|
|
|
'django.contrib.admin', |
|
|
|
'django.contrib.auth', |
|
|
|
'django.contrib.contenttypes', |
|
|
|
'django.contrib.sessions', |
|
|
|
'django.contrib.messages', |
|
|
|
'django.contrib.staticfiles', |
|
|
|
'rest_framework' |
|
|
|
] |
|
|
|
|
|
|
|
MIDDLEWARE_CLASSES = [ |
|
|
|
'django.middleware.security.SecurityMiddleware', |
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware', |
|
|
|
'django.middleware.common.CommonMiddleware', |
|
|
|
'django.middleware.csrf.CsrfViewMiddleware', |
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
|
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
|
|
|
'django.contrib.messages.middleware.MessageMiddleware', |
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware', |
|
|
|
] |
|
|
|
|
|
|
|
ROOT_URLCONF = 'lesspass.urls' |
|
|
|
|
|
|
|
TEMPLATES = [ |
|
|
|
{ |
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
|
|
'DIRS': [], |
|
|
|
'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 = 'lesspass.wsgi.application' |
|
|
|
|
|
|
|
DATABASES = { |
|
|
|
'default': { |
|
|
|
'ENGINE': 'django.db.backends.sqlite3', |
|
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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', |
|
|
|
}, |
|
|
|
] |
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us' |
|
|
|
|
|
|
|
TIME_ZONE = 'UTC' |
|
|
|
|
|
|
|
USE_I18N = True |
|
|
|
|
|
|
|
USE_L10N = True |
|
|
|
|
|
|
|
USE_TZ = True |
|
|
|
|
|
|
|
STATIC_URL = '/static/' |
|
|
|
|
|
|
|
REST_FRAMEWORK = { |
|
|
|
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',), |
|
|
|
'PAGE_SIZE': 100, |
|
|
|
'TEST_REQUEST_DEFAULT_FORMAT': 'json' |
|
|
|
} |