Skip to content
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

Suggested changes to configuration. #6

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions ptp/ptp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
SECRET_KEY = 'ptp_for_president_CC44aAFG'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

#DEBUG = True
if os.environ.get('DEBUG', False) == 'True':
DEBUG = True


ALLOWED_HOSTS = ['*', 'localhost']

Expand Down Expand Up @@ -61,11 +65,12 @@

WSGI_APPLICATION = 'ptp.wsgi.application'

DATABASE_DIR = os.environ.get('DATABASE_DIR', BASE_DIR)
# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': DATABASE_DIR / 'db.sqlite3',
}
}

Expand Down Expand Up @@ -103,18 +108,28 @@

# Media files (Uploaded files, results)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

MEDIA_DIR = os.environ.get('MEDIA_DIR', BASE_DIR)
MEDIA_ROOT = os.path.join(MEDIA_DIR, 'media')

# Email settings (for sending job completion notifications)
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Use console backend for testing
else:
if os.environ.get('EMAIL_HOST', False):
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.your-email-provider.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'your-email-password'
EMAIL_HOST = os.environ.get('EMAIL_HOST', 'smtp.example.com')
EMAIL_PORT = os.environ.get('EMAIL_PORT',587)
EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS',True)
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER','[email protected]')

# Not superfond of this..
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD','your-email-password')
# Perhaps?
if os.environ.get("EMAIL_PASSWORD_FILE", False):
filename = os.environ.get("EMAIL_PASSWORD_FILE", False)
with open(filename) as f:
EMAIL_HOST_PASSWORD = f.read().strip()

else:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Use console backend for testing

# Celery configuration
CELERY_BROKER_URL = "redis://localhost:6379/0"
Expand All @@ -133,7 +148,8 @@
# In production, it's better to use a cloud storage solution like AWS S3

# Set the SITE_URL for generating download links in emails
SITE_URL = 'https://yourdomain.com'

SITE_URL = os.environ.get('EMAIL_DOMAIN','https://yourdomain.com')

# Security settings
SECURE_BROWSER_XSS_FILTER = True
Expand Down
Loading