1111# DEBUG = config('DEBUG', default=False, cast=bool)
1212DEBUG = True
1313
14- # ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1,51.20.254.52").split(',')
15- ALLOWED_HOSTS = ["*" ]
16- INSTALLED_APPS = ['channels' ,'daphne' ,'django.contrib.admin' , 'django.contrib.auth' , 'django.contrib.contenttypes' , 'django.contrib.sessions' , 'django.contrib.messages' , 'django.contrib.staticfiles' , 'account.apps.AccountConfig' , 'rest_framework' , 'rest_framework_simplejwt' , 'rest_framework_simplejwt.token_blacklist' , 'corsheaders' , 'drf_spectacular' ,'chat.apps.ChatConfig' ]
14+ INSTALLED_APPS = ['django.contrib.admin' ,
15+ 'django.contrib.auth' ,
16+ 'django.contrib.contenttypes' ,
17+ 'django.contrib.sessions' ,
18+ 'django.contrib.messages' ,
19+ 'django.contrib.staticfiles' ,
20+ 'account.apps.AccountConfig' ,
21+ 'community' ,
22+ 'chatbot' ,
23+ 'rest_framework' ,
24+ 'rest_framework_simplejwt' ,
25+ 'rest_framework_simplejwt.token_blacklist' ,
26+ 'corsheaders' ,
27+ 'drf_spectacular' ,
28+ 'cloudinary' ,
29+ 'cloudinary_storage' ,]
1730
1831MIDDLEWARE = ['django.middleware.security.SecurityMiddleware' , 'whitenoise.middleware.WhiteNoiseMiddleware' , 'django.contrib.sessions.middleware.SessionMiddleware' , 'corsheaders.middleware.CorsMiddleware' , 'django.middleware.common.CommonMiddleware' , 'django.middleware.csrf.CsrfViewMiddleware' , 'django.contrib.auth.middleware.AuthenticationMiddleware' , 'django.contrib.messages.middleware.MessageMiddleware' , 'django.middleware.clickjacking.XFrameOptionsMiddleware' ]
1932
4558else :
4659 DATABASES = {'default' : {'ENGINE' : 'django.db.backends.sqlite3' , 'NAME' : BASE_DIR / 'db.sqlite3' }}
4760
61+ CLOUDINARY_STORAGE = {
62+ 'CLOUD_NAME' : config ('CLOUD_NAME' ),
63+ 'API_KEY' : config ('API_KEY' ),
64+ 'API_SECRET' : config ('API_SECRET' )
65+ }
66+
4867REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES' : ('rest_framework_simplejwt.authentication.JWTAuthentication' ,), 'DEFAULT_SCHEMA_CLASS' : 'drf_spectacular.openapi.AutoSchema' , 'DEFAULT_RENDERER_CLASSES' : ['rest_framework.renderers.JSONRenderer' , 'rest_framework.renderers.BrowsableAPIRenderer' ]}
4968
5069SPECTACULAR_SETTINGS = {'TITLE' : 'TripSync API' , 'DESCRIPTION' : 'TripSync - API Documentation' , 'VERSION' : '1.0.0' , 'SERVE_INCLUDE_SCHEMA' : False , 'CONTACT' : {'name' : 'TripSync Support' , 'email' : 'support@tripsync.com' }, 'LICENSE' : {'name' : 'MIT License' }, 'TAGS' : [{'name' : 'Authentication' , 'description' : 'User registration, login and token management' }, {'name' : 'Password Reset' , 'description' : 'Password reset functionality with OTP' }], 'SERVERS' : [{'url' : 'http://127.0.0.1:8000' , 'description' : 'Development server' }, {'url' : 'https://tripsync-backend-ruak.onrender.com' , 'description' : 'Production server' }], 'COMPONENT_SPLIT_REQUEST' : True , 'SWAGGER_UI_SETTINGS' : {'deepLinking' : True , 'persistAuthorization' : True , 'displayOperationId' : False , 'filter' : True }}
5675USE_I18N = True
5776USE_TZ = True
5877
59- STATIC_URL = '/static/'
60- STATIC_ROOT = BASE_DIR / 'staticfiles'
61- STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
62-
63- MEDIA_URL = '/media/'
64- MEDIA_ROOT = BASE_DIR / 'media'
65-
6678DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
6779
6880AUTH_USER_MODEL = 'account.User'
6981
7082SIMPLE_JWT = {'ACCESS_TOKEN_LIFETIME' : timedelta (hours = 1 ), 'REFRESH_TOKEN_LIFETIME' : timedelta (days = 7 ), 'ROTATE_REFRESH_TOKENS' : True , 'BLACKLIST_AFTER_ROTATION' : True , 'UPDATE_LAST_LOGIN' : True , 'ALGORITHM' : 'HS256' , 'SIGNING_KEY' : SECRET_KEY , 'AUTH_HEADER_TYPES' : ('Bearer' ,), 'USER_ID_FIELD' : 'id' , 'USER_ID_CLAIM' : 'user_id' , 'AUTH_TOKEN_CLASSES' : ('rest_framework_simplejwt.tokens.AccessToken' ,), 'TOKEN_TYPE_CLAIM' : 'token_type' }
7183
7284CORS_ALLOWED_ORIGINS = config ('CORS_ALLOWED_ORIGINS' , default = 'http://localhost:3000,http://localhost:5173' ).split (',' )
73-
7485CORS_ALLOW_ALL_ORIGINS = DEBUG
7586CORS_ALLOW_CREDENTIALS = True
76-
7787CORS_ALLOW_METHODS = ['DELETE' , 'GET' , 'OPTIONS' , 'PATCH' , 'POST' , 'PUT' ]
78-
79- CORS_ALLOW_HEADERS = ['accept' , 'accept-encoding' , 'authorization' , 'content-type' , 'dnt' , 'origin' , 'user-agent' , 'x-csrftoken' , 'x-requested-with' ,'sec-websocket-key' ,'sec-websocket-version' ,'sec-websocket-extensions' ]
88+ CORS_ALLOW_HEADERS = ['accept' , 'accept-encoding' , 'authorization' , 'content-type' , 'dnt' , 'origin' , 'user-agent' , 'x-csrftoken' , 'x-requested-with' ]
8089
8190if not DEBUG :
8291 SECURE_SSL_REDIRECT = False
116125OTP_EXPIRY_MINUTES = 10
117126MAX_OTP_ATTEMPTS = 5
118127OTP_LOCKOUT_HOURS = 1
119-
120- LOGGING = {'version' : 1 , 'disable_existing_loggers' : False , 'formatters' : {'verbose' : {'format' : '{levelname} {asctime} {module} {message}' , 'style' : '{' }}, 'handlers' : {'console' : {'class' : 'logging.StreamHandler' , 'formatter' : 'verbose' }}, 'root' : {'handlers' : ['console' ], 'level' : 'INFO' }, 'loggers' : {'django' : {'handlers' : ['console' ], 'level' : 'INFO' , 'propagate' : False }, 'account' : {'handlers' : ['console' ], 'level' : 'DEBUG' , 'propagate' : False }}}
128+ OTP_LOCKOUT_MINUTES = 15
129+
130+ LOGGING = {'version' : 1 , 'disable_existing_loggers' : False , 'formatters' : {'verbose' : {'format' : '{levelname} {asctime} {module} {message}' , 'style' : '{' }}, 'handlers' : {'console' : {'class' : 'logging.StreamHandler' , 'formatter' : 'verbose' }}, 'root' : {'handlers' : ['console' ], 'level' : 'INFO' }, 'loggers' : {'django' : {'handlers' : ['console' ], 'level' : 'INFO' , 'propagate' : False }, 'account' : {'handlers' : ['console' ], 'level' : 'DEBUG' , 'propagate' : False }}}
131+
132+ TWILIO_ACCOUNT_SID = config ('TWILIO_ACCOUNT_SID' , '' )
133+ TWILIO_AUTH_TOKEN = config ('TWILIO_AUTH_TOKEN' , '' )
134+ TWILIO_PHONE_NUMBER = config ('TWILIO_PHONE_NUMBER' , '' )
135+
136+ USE_S3 = config ('USE_S3' , default = False , cast = bool )
137+ if USE_S3 :
138+ AWS_ACCESS_KEY_ID = config ('AWS_ACCESS_KEY_ID' )
139+ AWS_SECRET_ACCESS_KEY = config ('AWS_SECRET_ACCESS_KEY' )
140+ AWS_BUCKET = config ('AWS_STORAGE_BUCKET_NAME' )
141+ S3_REGION = config ('AWS_S3_REGION_NAME' )
142+ S3_DOMAIN = f'tripsync-media.s3.amazonaws.com'
143+
144+ AWS_S3_OBJECT_PARAMETERS = {'CacheControl' : 'max-age=86400' ,}
145+ AWS_DEFAULT_ACL = 'public-read'
146+ AWS_S3_FILE_OVERWRITE = False
147+ AWS_QUERYSTRING_AUTH = False
148+ STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
149+ DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
150+ STATIC_URL = f'https://{ S3_DOMAIN } /static/'
151+ MEDIA_URL = f'https://{ S3_DOMAIN } /media/'
152+ else :
153+ STATIC_URL = '/static/'
154+ STATIC_ROOT = BASE_DIR / 'staticfiles'
155+ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
156+ MEDIA_ROOT = os .path .join (BASE_DIR , 'media' )
157+ MEDIA_URL = '/media/'
158+ DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
159+
160+ GOOGLE_API_KEY = config ('GOOGLE_API_KEY' )
0 commit comments