mirror of
https://github.com/macports/macports-webapp.git
synced 2026-07-13 03:18:42 -07:00
248 lines
6.1 KiB
Python
248 lines
6.1 KiB
Python
"""
|
|
Django settings for MacPorts project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.1.7.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/2.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/2.1/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = os.environ['SECRET_KEY']
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = False
|
|
|
|
ALLOWED_HOSTS = [
|
|
'*'
|
|
]
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.postgres',
|
|
'django.contrib.humanize',
|
|
'django.contrib.sites',
|
|
'django.contrib.admindocs',
|
|
'rest_framework',
|
|
'corsheaders',
|
|
'haystack',
|
|
'port',
|
|
'buildhistory',
|
|
'stats',
|
|
'maintainer',
|
|
'category',
|
|
'variant',
|
|
'user',
|
|
'django_filters',
|
|
|
|
'allauth',
|
|
'allauth.account',
|
|
'allauth.socialaccount',
|
|
'captcha',
|
|
|
|
# needed for GitHub login
|
|
'allauth.socialaccount.providers.github',
|
|
|
|
# django-notifications-hq
|
|
'notifications'
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
|
'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',
|
|
]
|
|
|
|
ROOT_URLCONF = 'urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [
|
|
TEMPLATE_DIR
|
|
],
|
|
'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',
|
|
'context_processor.footer_processor'
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
# needed by django admin panel
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
# needed for django-allauth
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
]
|
|
|
|
SOCIALACCOUNT_PROVIDERS = {
|
|
'github': {
|
|
'SCOPE': [
|
|
'read:user',
|
|
'user:email'
|
|
],
|
|
'VERIFIED_EMAIL': True
|
|
}
|
|
}
|
|
|
|
SITE_ID = 1
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
SOCIALACCOUNT_AUTO_SIGNUP = True
|
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
|
ACCOUNT_USERNAME_BLACKLIST = [
|
|
'macports',
|
|
'macports-ports',
|
|
'macports-org',
|
|
'macports-webapp',
|
|
'port',
|
|
'ports'
|
|
]
|
|
ACCOUNT_AUTHENTICATION_METHOD ="username_email"
|
|
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
|
|
SOCIALACCOUNT_EMAIL_VERIFICATION = False
|
|
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
|
|
|
|
WSGI_APPLICATION = 'wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': os.environ['DB_NAME'],
|
|
'USER': os.environ['DB_USER'],
|
|
'PASSWORD': os.environ['DB_PASSWORD'],
|
|
'HOST': os.environ['DB_HOST'],
|
|
'PORT': os.environ.get('DB_PORT', '5432'),
|
|
}
|
|
}
|
|
|
|
# django-haystack configuration
|
|
HAYSTACK_CONNECTIONS = {
|
|
'default': {
|
|
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
|
|
'URL': os.environ['SOLR_URL'],
|
|
'ADMIN_URL': os.environ['SOLR_ADMIN_URL']
|
|
},
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/2.1/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.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'static'),
|
|
]
|
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
|
'PAGE_SIZE': 50
|
|
}
|
|
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
'LOCATION': '127.0.0.1:11211',
|
|
}
|
|
}
|
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
EMAIL_HOST = os.environ.get('EMAIL_HOST')
|
|
EMAIL_PORT = os.environ.get('EMAIL_PORT')
|
|
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
|
|
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
|
EMAIL_USE_TLS = True
|
|
EMAIL_USE_SSL = False
|
|
DEFAULT_FROM_EMAIL = os.environ.get('FROM_EMAIL', 'no-reply@ports.macports.org')
|
|
|
|
|
|
DJANGO_NOTIFICATIONS_CONFIG = {
|
|
'USE_JSONFIELD': True,
|
|
'SOFT_DELETE': True
|
|
}
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
|
|
# Configuration for RECAPTCHA
|
|
RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', '')
|
|
RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', '')
|
|
|
|
RECAPTCHA_USE_SSL = True
|
|
|
|
# Override default django-allauth form with this one.
|
|
# It adds the recaptcha field
|
|
ACCOUNT_SIGNUP_FORM_CLASS = 'user.forms.AllAuthSignupForm'
|