242 lines
6.3 KiB
Python
242 lines
6.3 KiB
Python
"""
|
|
Django settings for photo21 project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.2.24.
|
|
|
|
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/
|
|
"""
|
|
|
|
import os
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django.contrib.messages import constants as messages
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'CHANGE_ME'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = [
|
|
"127.0.0.1",
|
|
"localhost",
|
|
"photos.crans.org",
|
|
"photos-dev.crans.org",
|
|
]
|
|
|
|
# Admins receive server errors, this is useful to be notified of potential bugs
|
|
ADMINS = [
|
|
('erdnaxe', 'a+photo21@crans.org'),
|
|
]
|
|
|
|
# Managers receive notifications about new photos upload
|
|
MANAGERS = [
|
|
('moderation', 'photos@crans.org'),
|
|
]
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.admindocs',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.sites',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'allauth',
|
|
'allauth.account',
|
|
'allauth.socialaccount',
|
|
'allauth_note_kfet',
|
|
'crispy_forms',
|
|
'photologue_custom',
|
|
'photologue',
|
|
'sortedm2m',
|
|
'taggit',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'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.middleware.locale.LocaleMiddleware',
|
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'photo21.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [os.path.join(BASE_DIR, 'photo21/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',
|
|
'django.template.context_processors.request',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
# Needed to login by username in Django admin, regardless of `allauth`
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
# `allauth` specific authentication methods, such as login by e-mail
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
]
|
|
|
|
WSGI_APPLICATION = 'photo21.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
}
|
|
}
|
|
|
|
|
|
# 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',
|
|
},
|
|
]
|
|
|
|
PASSWORD_HASHERS = [
|
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
|
'photo21.hashers.SHA512PasswordHasher',
|
|
]
|
|
|
|
|
|
# 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
|
|
|
|
# Limit available languages to this subset
|
|
LANGUAGES = [
|
|
('de', _('German')),
|
|
('en', _('English')),
|
|
('es', _('Spanish')),
|
|
('fr', _('French')),
|
|
]
|
|
|
|
# Allow more fields in URL to edit large galleries
|
|
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'photo21/static'),
|
|
]
|
|
|
|
# Collect statics to /static/
|
|
# THIS FOLDER SOULD NOT BE IN GIT TREE!!!
|
|
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
|
|
|
|
# Use /media/ for user uploaded media
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
|
MEDIA_URL = '/media/'
|
|
|
|
LOCALE_PATHS = [os.path.join(BASE_DIR, 'photo21/locale')]
|
|
|
|
FIXTURE_DIRS = [os.path.join(BASE_DIR, 'photo21/fixtures')]
|
|
|
|
# Email settings
|
|
if DEBUG:
|
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
|
else:
|
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
EMAIL_USE_SSL = os.getenv('EMAIL_USE_SSL', False)
|
|
EMAIL_HOST = os.getenv('EMAIL_HOST', 'smtp.crans.org')
|
|
EMAIL_PORT = os.getenv('EMAIL_PORT', 25)
|
|
EMAIL_HOST_USER = os.getenv('EMAIL_USER', None)
|
|
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD', None)
|
|
|
|
# Mail will be sent from this address
|
|
SERVER_EMAIL = "photos@crans.org"
|
|
DEFAULT_FROM_EMAIL = f"Serveur photos <{SERVER_EMAIL}>"
|
|
EMAIL_SUBJECT_PREFIX = '[Serveur photos] '
|
|
|
|
# After login redirect user to transfer page
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
# An user session will expired after 3 hours
|
|
SESSION_COOKIE_AGE = 60 * 60 * 3
|
|
|
|
# Use only one Django Sites
|
|
SITE_ID = 1
|
|
|
|
# Django message
|
|
MESSAGE_TAGS = {
|
|
messages.DEBUG: 'alert-secondary',
|
|
messages.INFO: 'alert-info',
|
|
messages.SUCCESS: 'alert-success',
|
|
messages.WARNING: 'alert-warning',
|
|
messages.ERROR: 'alert-danger',
|
|
}
|
|
|
|
# Allauth configuration
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
|
|
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
|
|
ACCOUNT_FORMS = {'signup': 'photo21.forms.CustomSignupForm'}
|
|
SOCIALACCOUNT_PROVIDERS = {
|
|
'notekfet': {
|
|
# Fetch user profile
|
|
'SCOPE': ['1_1'],
|
|
},
|
|
}
|
|
|
|
# Use Bootstrap forms
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
|
|
|
# Photologue
|
|
PHOTOLOGUE_GALLERY_SAMPLE_SIZE = 1
|