Add multi-image compositions, docker setup, tests, and docs
- Add CompositionImage model with multi-image upload and main image flag - Add composition endpoints: add-images, set-main-image, delete image, by-created-at filter - Make contact-us by_category public - Add 24 API tests covering all endpoints - Add Dockerfile, docker-compose, entrypoint and docker docs - Add Persian API docs and update README and Postman collection Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -20,16 +21,24 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-ro-sqgr@$*(qao)@d&ezk*z9&%+vbeurgi$b+6y650j*$1b+n5'
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-ro-sqgr@$*(qao)@d&ezk*z9&%+vbeurgi$b+6y650j*$1b+n5')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
# Default to False for production safety - set DEBUG=True only in development
|
||||
DEBUG = os.environ.get('DEBUG', 'False') == 'True'
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'localhost',
|
||||
'127.0.0.1',
|
||||
'185.208.172.158',
|
||||
]
|
||||
# Allow all hosts in development mode for network access
|
||||
# In production, ALLOWED_HOSTS MUST be set via environment variable
|
||||
if DEBUG:
|
||||
ALLOWED_HOSTS = ['*'] # Allow all hosts in development only
|
||||
else:
|
||||
# Production: require ALLOWED_HOSTS to be set explicitly
|
||||
allowed_hosts_env = os.environ.get('ALLOWED_HOSTS')
|
||||
if allowed_hosts_env:
|
||||
ALLOWED_HOSTS = allowed_hosts_env.split(',')
|
||||
else:
|
||||
# Fallback for production (should be overridden by env var)
|
||||
ALLOWED_HOSTS = ['185.208.172.158'] # Your server IP
|
||||
|
||||
|
||||
# Application definition
|
||||
@@ -86,11 +95,11 @@ WSGI_APPLICATION = 'zonco_backend.wsgi.application'
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'Zoneco_ORG',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'postgres',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
'NAME': os.environ.get('POSTGRES_DB', 'Zoneco_ORG'),
|
||||
'USER': os.environ.get('POSTGRES_USER', 'postgres'),
|
||||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'postgres'),
|
||||
'HOST': os.environ.get('POSTGRES_HOST', 'localhost'),
|
||||
'PORT': os.environ.get('POSTGRES_PORT', '5432'),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,14 +168,23 @@ REST_FRAMEWORK = {
|
||||
}
|
||||
|
||||
# CORS configuration
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:5173", # Vite default port
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:5173",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://185.208.172.158:9123",
|
||||
"http://185.208.172.158",
|
||||
]
|
||||
# In development, allow all origins for easier testing
|
||||
# In production, CORS_ALLOWED_ORIGINS MUST be set via environment variable
|
||||
if DEBUG:
|
||||
CORS_ALLOW_ALL_ORIGINS = True # Development only - allows all origins
|
||||
else:
|
||||
# Production: require CORS_ALLOWED_ORIGINS to be set explicitly
|
||||
cors_origins_env = os.environ.get('CORS_ALLOWED_ORIGINS')
|
||||
if cors_origins_env:
|
||||
CORS_ALLOWED_ORIGINS = cors_origins_env.split(',')
|
||||
else:
|
||||
# Fallback for production (should be overridden by env var)
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
'http://185.208.172.158:9123',
|
||||
'http://185.208.172.158',
|
||||
'https://185.208.172.158:9123',
|
||||
'https://185.208.172.158',
|
||||
]
|
||||
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user