-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
website: updating settings file #4035
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ def require_env_var(env_var: str) -> str: | |
ALLOWED_HOSTS = parse_env_list('ALLOWED_HOSTS', default='localhost,127.0.0.1') | ||
|
||
# --------------------------------------------------------- | ||
# Applications | ||
# Installed Apps | ||
# --------------------------------------------------------- | ||
INSTALLED_APPS = [ | ||
# Django Defaults | ||
|
@@ -115,9 +115,11 @@ def require_env_var(env_var: str) -> str: | |
CORS_ALLOWED_ORIGIN_REGEXES = parse_env_list('CORS_ORIGIN_REGEX_WHITELIST') | ||
CSRF_TRUSTED_ORIGINS = parse_env_list('CSRF_TRUSTED_ORIGINS') | ||
|
||
# If no CORS settings provided, consider defaulting to empty lists | ||
CORS_ALLOWED_ORIGINS = CORS_ALLOWED_ORIGINS if CORS_ALLOWED_ORIGINS else [] | ||
CORS_ALLOWED_ORIGIN_REGEXES = CORS_ALLOWED_ORIGIN_REGEXES if CORS_ALLOWED_ORIGIN_REGEXES else [] | ||
# Ensure no trailing slashes and correct schemes | ||
CORS_ALLOWED_ORIGINS = [origin.rstrip('/') for origin in CORS_ALLOWED_ORIGINS] | ||
CORS_ALLOWED_ORIGIN_REGEXES = [regex.rstrip( | ||
'/') for regex in CORS_ALLOWED_ORIGIN_REGEXES] | ||
CSRF_TRUSTED_ORIGINS = [origin.rstrip('/') for origin in CSRF_TRUSTED_ORIGINS] | ||
|
||
# Security cookies | ||
CSRF_COOKIE_SECURE = not DEBUG | ||
|
@@ -269,3 +271,150 @@ def require_env_var(env_var: str) -> str: | |
'scrollingContainer': '#scrolling-container', | ||
}, | ||
} | ||
|
||
# --------------------------------------------------------- | ||
# File Upload Settings | ||
# --------------------------------------------------------- | ||
# Increase these values as needed to handle larger uploads | ||
FILE_UPLOAD_MAX_MEMORY_SIZE = 10485760 # 10 MB | ||
DATA_UPLOAD_MAX_MEMORY_SIZE = 10485760 # 10 MB | ||
|
||
# --------------------------------------------------------- | ||
# SSL and Proxy Settings (if behind a reverse proxy) | ||
# --------------------------------------------------------- | ||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | ||
USE_X_FORWARDED_HOST = True | ||
|
||
# --------------------------------------------------------- | ||
# Logging Configuration | ||
# --------------------------------------------------------- | ||
LOG_DIR = BASE_DIR / 'logs' | ||
LOG_DIR.mkdir(exist_ok=True) # Ensure log directory exists | ||
Comment on lines
+291
to
+292
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid side effects in Creating directories within |
||
|
||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
# Formatters | ||
'formatters': { | ||
'verbose': { | ||
'format': '[%(asctime)s] %(levelname)s %(name)s [%(filename)s:%(lineno)d] %(message)s', | ||
'datefmt': '%Y-%m-%d %H:%M:%S' | ||
}, | ||
'simple': { | ||
'format': '%(levelname)s %(message)s' | ||
}, | ||
}, | ||
# Handlers | ||
'handlers': { | ||
'console': { | ||
'class': 'logging.StreamHandler', | ||
'formatter': 'verbose', | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
}, | ||
'file': { | ||
'class': 'logging.FileHandler', | ||
'filename': LOG_DIR / 'django.log', | ||
'formatter': 'verbose', | ||
'level': 'INFO', | ||
}, | ||
'error_file': { | ||
'class': 'logging.FileHandler', | ||
'filename': LOG_DIR / 'django_errors.log', | ||
'formatter': 'verbose', | ||
'level': 'ERROR', | ||
}, | ||
}, | ||
# Loggers | ||
'loggers': { | ||
# Django Logs | ||
'django': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'INFO', | ||
'propagate': True, | ||
}, | ||
# Cloudinary Logs | ||
'cloudinary': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'INFO', | ||
'propagate': True, | ||
}, | ||
# Event App Logs | ||
'apps.event': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# CleanAir App Logs | ||
'apps.cleanair': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# AfricanCities App Logs | ||
'apps.africancities': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Publications App Logs | ||
'apps.publications': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Press App Logs | ||
'apps.press': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Impact App Logs | ||
'apps.impact': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# FAQs App Logs | ||
'apps.faqs': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Highlights App Logs | ||
'apps.highlights': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Career App Logs | ||
'apps.career': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Partners App Logs | ||
'apps.partners': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Board App Logs | ||
'apps.board': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# Team App Logs | ||
'apps.team': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
# ExternalTeams App Logs | ||
'apps.externalteams': { | ||
'handlers': ['console', 'file', 'error_file'], | ||
'level': 'DEBUG' if DEBUG else 'INFO', | ||
'propagate': False, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ensure SSL and proxy settings align with deployment environment
Enabling
SECURE_PROXY_SSL_HEADER
andUSE_X_FORWARDED_HOST
is appropriate when the application is behind a reverse proxy that sets theX-Forwarded-Proto
header, such as Nginx. If this isn't always the case, consider making these settings conditional based on an environment variable to prevent potential misconfigurations in other environments.