|
|
|
"""
|
|
|
|
Django settings for xmrauctions project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 2.2.7.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/2.2/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/2.2/ref/settings/
|
|
|
|
|
|
|
|
For the production deployment checklist, see
|
|
|
|
https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
from core.monero import AuctionWallet
|
|
|
|
|
|
|
|
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
SITE_NAME = os.environ.get('SITE_NAME', 'XMR Auctions')
|
|
|
|
SITE_URL = os.environ.get('SITE_URL', '127.0.0.1:8000')
|
|
|
|
SECRET_KEY = os.environ['SECRET_KEY']
|
|
|
|
DEBUG = os.environ.get('DEBUG', False)
|
|
|
|
ALLOWED_HOSTS = str(os.environ['ALLOWED_HOSTS']).split(',')
|
|
|
|
ALLOWED_HOSTS.append('gunicorn')
|
|
|
|
ESCROW_PERIOD_DAYS = os.environ.get('ESCROW_PERIOD_DAYS', 30)
|
|
|
|
STALE_PERIOD_DAYS = os.environ.get('STALE_PERIOD_DAYS', 21)
|
|
|
|
PLATFORM_FEE_PERCENT = os.environ.get('PLATFORM_FEE_PERCENT', 0)
|
|
|
|
BLOCK_CONFIRMATIONS_RCV = os.environ.get('BLOCK_CONFIRMATIONS_RCV', 3)
|
|
|
|
BLOCK_EXPLORER = 'https://community.xmr.to/explorer/%s'
|
|
|
|
DEVOPS_DASHBOARD = os.environ.get('DEVOPS_DASHBOARD', None)
|
|
|
|
|
|
|
|
|
|
|
|
# Social
|
|
|
|
|
|
|
|
IRC_USER = os.environ.get('IRC_USER', 'lza_menace')
|
|
|
|
TWITTER_USER = os.environ.get('TWITTER_USER', 'lza_menace')
|
|
|
|
GITHUB_USER = os.environ.get('GITHUB_USER', 'lalanza808')
|
|
|
|
|
|
|
|
SOCIAL_MEDIA = {
|
|
|
|
'fas fa-comment-dots': {
|
|
|
|
'url': 'https://webchat.freenode.net/?room=#monero',
|
|
|
|
'comment': f'Monero IRC - @{IRC_USER}'
|
|
|
|
},
|
|
|
|
'fab fa-twitter': {
|
|
|
|
'url': f'https://twitter.com/{TWITTER_USER}',
|
|
|
|
'comment': f'Twitter - @{TWITTER_USER}'
|
|
|
|
},
|
|
|
|
'fab fa-github': {
|
|
|
|
'url': f'https://github.com/{GITHUB_USER}',
|
|
|
|
'comment': f'Github - @{GITHUB_USER}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
'bids.apps.BidsConfig',
|
|
|
|
'items.apps.ItemsConfig',
|
|
|
|
'sales.apps.SalesConfig',
|
|
|
|
'core.apps.CoreConfig',
|
|
|
|
'huey.contrib.djhuey',
|
|
|
|
'corsheaders',
|
|
|
|
'anymail',
|
|
|
|
'django_prometheus'
|
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
|
|
|
'django_prometheus.middleware.PrometheusBeforeMiddleware',
|
|
|
|
'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',
|
|
|
|
'django_prometheus.middleware.PrometheusAfterMiddleware'
|
|
|
|
]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'xmrauctions.urls'
|
|
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
LOGOUT_REDIRECT_URL = '/'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [os.path.join(BASE_DIR, 'web/templates')],
|
|
|
|
'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',
|
|
|
|
'xmrauctions.context_processors.inject_site_meta'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'xmrauctions.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': os.environ.get('DB_ENGINE', 'django_prometheus.db.backends.postgresql'),
|
|
|
|
'NAME': os.environ['DB_NAME'],
|
|
|
|
'PASSWORD': os.environ['DB_PASS'],
|
|
|
|
'PORT': os.environ.get('DB_PORT', 5432),
|
|
|
|
'USER': os.environ['DB_USER'],
|
|
|
|
'HOST': os.environ['DB_HOST']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Cache
|
|
|
|
# https://docs.djangoproject.com/en/2.2/topics/cache/
|
|
|
|
|
|
|
|
CACHE_HOST = os.environ.get('CACHE_HOST', 'localhost')
|
|
|
|
CACHE_PORT = os.environ.get('CACHE_PORT', 6379)
|
|
|
|
CACHE_TTL = os.environ.get('CACHE_TTL', 3600)
|
|
|
|
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
|
|
|
'LOCATION': f'redis://{CACHE_HOST}:{CACHE_PORT}/1',
|
|
|
|
'OPTIONS': {
|
|
|
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient'
|
|
|
|
},
|
|
|
|
'KEY_PREFIX': 'xmrauctions'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HUEY = {
|
|
|
|
'huey_class': 'huey.RedisHuey',
|
|
|
|
'name': DATABASES['default']['NAME'],
|
|
|
|
'results': True,
|
|
|
|
'store_none': True,
|
|
|
|
'immediate': False,
|
|
|
|
'utc': True,
|
|
|
|
'blocking': True,
|
|
|
|
'connection': {
|
|
|
|
'host': CACHE_HOST,
|
|
|
|
'port': CACHE_PORT,
|
|
|
|
'db': 0,
|
|
|
|
'connection_pool': None,
|
|
|
|
'read_timeout': 1,
|
|
|
|
'url': None,
|
|
|
|
},
|
|
|
|
'consumer': {
|
|
|
|
'workers': 1,
|
|
|
|
'worker_type': 'thread',
|
|
|
|
'initial_delay': 1,
|
|
|
|
'backoff': 1.15,
|
|
|
|
'max_delay': 10.0,
|
|
|
|
'scheduler_interval': 1,
|
|
|
|
'periodic': True,
|
|
|
|
'check_worker_health': True,
|
|
|
|
'health_check_interval': 5,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# Sessions
|
|
|
|
|
|
|
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
|
|
|
SESSION_COOKIE_AGE = os.environ.get('SESSION_COOKIE_AGE', 3600)
|
|
|
|
|
|
|
|
|
|
|
|
# Messages
|
|
|
|
|
|
|
|
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
|
|
|
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
|
|
|
|
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
|
|
|
|
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
|
|
|
|
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images) and storage backend
|
|
|
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
|
|
|
|
|
if DEBUG:
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
|
|
else:
|
|
|
|
STATICFILES_LOCATION = 'static'
|
|
|
|
MEDIA_LOCATION = 'media'
|
|
|
|
AWS_STORAGE_BUCKET_NAME = os.getenv('AWS_STORAGE_BUCKET_NAME')
|
|
|
|
AWS_DEFAULT_ACL = None
|
|
|
|
AWS_S3_CUSTOM_DOMAIN = os.getenv('AWS_S3_CUSTOM_DOMAIN')
|
|
|
|
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
|
|
|
|
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/media/'
|
|
|
|
STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/static/'
|
|
|
|
DEFAULT_FILE_STORAGE = 'xmrauctions.storages.MediaStorage'
|
|
|
|
STATICFILES_STORAGE = 'xmrauctions.storages.StaticStorage'
|
|
|
|
|
|
|
|
|
|
|
|
STATICFILES_DIRS = [
|
|
|
|
os.path.join(BASE_DIR, "web/static")
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# django-registration
|
|
|
|
|
|
|
|
ACCOUNT_ACTIVATION_DAYS = os.environ.get('ACCOUNT_ACTIVATION_DAYS', 7)
|
|
|
|
REGISTRATION_OPEN = os.environ.get('REGISTRATION_OPEN', True)
|
|
|
|
REGISTRATION_SALT = os.environ.get('REGISTRATION_SALT', 'registration')
|
|
|
|
|
|
|
|
|
|
|
|
# Monero Daemon/Wallet RPC settings
|
|
|
|
|
|
|
|
DAEMON_HOST = os.environ.get('DAEMON_HOST', '127.0.0.1')
|
|
|
|
DAEMON_PORT = os.environ.get('DAEMON_PORT', '38081')
|
|
|
|
DAEMON_USER = os.environ.get('DAEMON_USER', '')
|
|
|
|
DAEMON_PASS = os.environ.get('DAEMON_PASS', '')
|
|
|
|
WALLET_HOST = os.environ.get('WALLET_HOST', '127.0.0.1')
|
|
|
|
WALLET_PORT = os.environ.get('WALLET_PORT', '8080')
|
|
|
|
WALLET_USER = os.environ.get('WALLET_USER', '')
|
|
|
|
WALLET_PASS = os.environ.get('WALLET_PASS', '')
|
|
|
|
|
|
|
|
|
|
|
|
# Email info
|
|
|
|
|
|
|
|
EMAIL_DOMAIN = os.environ.get('EMAIL_DOMAIN', 'localhost')
|
|
|
|
EMAIL_FROM = os.environ.get('EMAIL_FROM', 'noreply')
|
|
|
|
DEFAULT_FROM_EMAIL = f'{SITE_NAME} <{EMAIL_FROM}@{EMAIL_DOMAIN}>'
|
|
|
|
SERVER_EMAIL = DEFAULT_FROM_EMAIL
|
|
|
|
ANYMAIL = {
|
|
|
|
'MAILGUN_API_KEY': os.environ.get('MAILGUN_API_KEY', None),
|
|
|
|
"MAILGUN_SENDER_DOMAIN": os.environ.get('MAILGUN_SENDER_DOMAIN', EMAIL_DOMAIN),
|
|
|
|
}
|
|
|
|
|
|
|
|
if ANYMAIL['MAILGUN_API_KEY']:
|
|
|
|
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
|
|
|
|
else:
|
|
|
|
EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend')
|
|
|
|
|
|
|
|
|
|
|
|
# CORS
|
|
|
|
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = os.environ.get('CORS_ORIGIN_ALLOW_ALL', False)
|
|
|
|
CORS_ORIGIN_WHITELIST = os.environ.get('CORS_ORIGIN_WHITELIST', [])
|
|
|
|
CORS_ORIGIN_REGEX_WHITELIST = [
|
|
|
|
r"^https://static\.\w+\.xmrauctions\.com$",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# Platform Wallets
|
|
|
|
|
|
|
|
|
|
|
|
aw = AuctionWallet()
|
|
|
|
platform_wallet_address = None
|
|
|
|
if aw.connected is True:
|
|
|
|
platform_wallet_address = str(aw.wallet.accounts[0].address())
|
|
|
|
|
|
|
|
PLATFORM_WALLET_ADDRESS = os.environ.get('PLATFORM_WALLET_ADDRESS', platform_wallet_address)
|
|
|
|
TIP_WALLET_ADDRESS = os.environ.get('TIP_ADDRESS', PLATFORM_WALLET_ADDRESS)
|