You've already forked opc-backend
109 lines
3.4 KiB
Python
109 lines
3.4 KiB
Python
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||
|
|
|
||
|
|
# Load .env file
|
||
|
|
env_file = BASE_DIR / '.env'
|
||
|
|
if env_file.exists():
|
||
|
|
with open(env_file, 'r', encoding='utf-8') as f:
|
||
|
|
for line in f:
|
||
|
|
line = line.strip()
|
||
|
|
if line and not line.startswith('#'):
|
||
|
|
key, val = line.split('=', 1)
|
||
|
|
os.environ[key.strip()] = val.strip().strip("'").strip('"')
|
||
|
|
|
||
|
|
SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-opc-community-platform')
|
||
|
|
DEBUG = os.environ.get('DEBUG', 'True') == 'True'
|
||
|
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '*').split(',')
|
||
|
|
|
||
|
|
INSTALLED_APPS = [
|
||
|
|
'django.contrib.admin',
|
||
|
|
'django.contrib.auth',
|
||
|
|
'django.contrib.contenttypes',
|
||
|
|
'django.contrib.sessions',
|
||
|
|
'django.contrib.messages',
|
||
|
|
'django.contrib.staticfiles',
|
||
|
|
'rest_framework',
|
||
|
|
'corsheaders',
|
||
|
|
'users',
|
||
|
|
'tasks',
|
||
|
|
'reservations',
|
||
|
|
'opc_cert',
|
||
|
|
'system',
|
||
|
|
]
|
||
|
|
|
||
|
|
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 = 'core.urls'
|
||
|
|
CORS_ALLOW_ALL_ORIGINS = os.environ.get('CORS_ALLOW_ALL_ORIGINS', 'True') == 'True'
|
||
|
|
|
||
|
|
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 = 'core.wsgi.application'
|
||
|
|
|
||
|
|
DATABASES = {
|
||
|
|
'default': {
|
||
|
|
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.postgresql'),
|
||
|
|
'NAME': os.environ.get('DB_NAME', 'opc_db'),
|
||
|
|
'USER': os.environ.get('DB_USER', 'opc_user'),
|
||
|
|
'PASSWORD': os.environ.get('DB_PASSWORD', 'opc_password'),
|
||
|
|
'HOST': os.environ.get('DB_HOST', 'localhost'),
|
||
|
|
'PORT': os.environ.get('DB_PORT', '5432'),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
AUTH_PASSWORD_VALIDATORS = []
|
||
|
|
|
||
|
|
LANGUAGE_CODE = 'zh-hans'
|
||
|
|
TIME_ZONE = 'Asia/Shanghai'
|
||
|
|
USE_I18N = True
|
||
|
|
USE_TZ = True
|
||
|
|
|
||
|
|
STATIC_URL = 'static/'
|
||
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||
|
|
|
||
|
|
AUTH_USER_MODEL = 'users.User'
|
||
|
|
|
||
|
|
REST_FRAMEWORK = {
|
||
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||
|
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||
|
|
),
|
||
|
|
'DEFAULT_PERMISSION_CLASSES': (
|
||
|
|
'rest_framework.permissions.IsAuthenticated',
|
||
|
|
),
|
||
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||
|
|
'PAGE_SIZE': 20,
|
||
|
|
}
|
||
|
|
|
||
|
|
# MinIO Configuration
|
||
|
|
MINIO_ENDPOINT = os.environ.get('MINIO_ENDPOINT', 'localhost:9000')
|
||
|
|
MINIO_ACCESS_KEY = os.environ.get('MINIO_ACCESS_KEY', 'minioadmin')
|
||
|
|
MINIO_SECRET_KEY = os.environ.get('MINIO_SECRET_KEY', 'minioadmin')
|
||
|
|
MINIO_BUCKET_NAME = os.environ.get('MINIO_BUCKET_NAME', 'opc-assets')
|
||
|
|
MINIO_SECURE = os.environ.get('MINIO_SECURE', 'False') == 'True'
|
||
|
|
MINIO_PUBLIC_URL = os.environ.get('MINIO_PUBLIC_URL', 'http://127.0.0.1:9000')
|