This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
Episodes.Community/EpisodesCommunity/settings.py

183 lines
5.3 KiB
Python
Raw Permalink Normal View History

2017-12-28 10:39:02 +00:00
# Episodes.Community - Community-Driven TV Show Episode Link Sharing Site
# Copyright (C) 2017 Evert "Diamond" Prants <evert@lunasqu.ee>, Taizo "Tsa6" Simpson <taizo@tsa6.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2017-08-22 21:03:11 +00:00
"""
Django settings for EpisodesCommunity project.
Generated by 'django-admin startproject' using Django 1.11.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
2017-09-21 21:20:40 +00:00
import dj_database_url
2017-08-22 21:03:11 +00:00
import os
2017-09-21 21:07:42 +00:00
import configparser
import warnings
2017-09-21 22:01:35 +00:00
import base64
2017-09-21 21:07:42 +00:00
config = configparser.ConfigParser()
config.read('options.ini')
options = config['General']
2017-09-21 22:01:35 +00:00
oauth_options = config['OAuth']
2017-08-22 21:03:11 +00:00
# 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/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
2017-09-21 21:07:42 +00:00
SECRET_KEY = options.get('secret_key', '5up3r s3cr3t k3y')
if '5up3r s3cr3t k3y' == SECRET_KEY:
warnings.warn("Using a default secret_key, change this in options.ini for production!")
2017-08-22 21:03:11 +00:00
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
AUTHENTICATION_BACKENDS = (
'LandingPage.backends.OAuthBackend',
2017-12-11 17:23:19 +00:00
'guardian.backends.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend',
)
AUTH_USER_MODEL = 'LandingPage.User'
2017-08-22 21:03:11 +00:00
INSTALLED_APPS = [
2017-08-25 19:50:07 +00:00
'LandingPage.apps.LandingpageConfig',
'Show.apps.ShowConfig',
'Discussions.apps.DiscussionsConfig',
2017-08-22 21:03:11 +00:00
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
2017-12-11 17:23:19 +00:00
'guardian',
'widget_tweaks'
2017-08-22 21:03:11 +00:00
]
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 = 'EpisodesCommunity.urls'
LOGIN_URL = '/login'
2017-08-22 21:03:11 +00:00
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'EpisodesCommunity.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': dj_database_url.parse(options.get("database", 'sqlite:///database.sqlite3'))
2017-08-22 21:03:11 +00:00
}
# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/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/1.11/howto/static-files/
2017-10-05 10:37:09 +00:00
MEDIA_URL = '/media/'
MEDIA_ROOT = 'media/'
2017-08-22 21:03:11 +00:00
STATIC_URL = '/static/'
2017-10-05 10:37:09 +00:00
STATIC_ROOT = 'static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
2017-09-21 22:01:35 +00:00
2017-10-05 10:37:09 +00:00
AUTH_TOKEN_ENDPOINT = oauth_options.get('token_endpoint','https://icynet.eu/oauth2/')
AUTH_CLIENT_ID = oauth_options.get('client_id')
AUTH_B64 = base64.b64encode(bytearray('%s:%s'%(AUTH_CLIENT_ID,oauth_options.get('client_secret')),'utf-8')).decode("utf-8")
2017-09-21 22:01:35 +00:00
AUTH_REDIRECT_URL = oauth_options.get('redirect_url')
2018-02-27 22:06:41 +00:00
DISCUSSIONS_PER_PAGE = 26
2018-02-28 16:34:10 +00:00
DISCUSSIONS_REPLIES_PER_PAGE = 10
# Domain of this app
2018-03-02 13:46:25 +00:00
DOMAIN=options.get('domain')
# Use subdomains for each show
2018-03-02 13:46:25 +00:00
DOMAIN_SUBDOMAIN_SHOWS=options.get('use_subdomain_paths') == 'true'