148 lines
3.7 KiB
Python
148 lines
3.7 KiB
Python
"""
|
|
Django settings for mauflix project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.2.4.
|
|
|
|
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
|
|
import re
|
|
|
|
from .conf import (
|
|
DEBUG,
|
|
DEFAULT_DB,
|
|
SECRET_KEY,
|
|
TOKEN_MASTODON,
|
|
TOKEN_TELEGRAM,
|
|
CHAT_ID,
|
|
API_TOKEN,
|
|
)
|
|
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
PATH_TEMPLATES = os.path.join(BASE_DIR, 'templates')
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
|
MEDIA_URL = 'media/'
|
|
|
|
|
|
ALLOWED_HOSTS = ['mauflix.elmau.net', 'elmau.net']
|
|
if DEBUG:
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
# ~ 'mauflix.apps.SuitConfig',
|
|
'django_admin_listfilter_dropdown',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'main.apps.MainConfig',
|
|
]
|
|
|
|
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',
|
|
]
|
|
|
|
ROOT_URLCONF = 'mauflix.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [PATH_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',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'mauflix.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
|
|
DATABASES = {'default': DEFAULT_DB}
|
|
|
|
|
|
# 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 = 'es-MX'
|
|
|
|
TIME_ZONE = 'America/Mexico_City'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = False
|
|
|
|
|
|
# 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, 'static')]
|
|
|
|
DISALLOWED_USER_AGENTS = (
|
|
re.compile(r'.*Googlebot', re.IGNORECASE),
|
|
re.compile(r'.*Spider', re.IGNORECASE),
|
|
re.compile(r'.*bingbot', re.IGNORECASE),
|
|
re.compile(r'.*MJ12bot', re.IGNORECASE),
|
|
re.compile(r'.*Slurp', re.IGNORECASE),
|
|
re.compile(r'.*python-requests', re.IGNORECASE),
|
|
re.compile(r'.*Netcraft', re.IGNORECASE),
|
|
re.compile(r'.*AhrefsBot', re.IGNORECASE),
|
|
)
|
|
|
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
|
SESSION_COOKIE_AGE = 3600
|
|
|
|
|
|
# ~ URL_CDN = 'https://sos-ch-dk-2.exo.io/mauflix/{}/{}'
|
|
URL_CDN = 'https://mauflix.elmau.net/{}'
|
|
URL_MASTODON = 'https://mstdn.mx/'
|