Settiings check and cleanup.

This commit is contained in:
Martin Mahner 2018-06-23 15:17:03 +02:00
parent cd81a68182
commit 99629d6cd6
2 changed files with 31 additions and 34 deletions

View file

@ -1,9 +1,9 @@
# Import global settings to make it easier to extend settings.
from django.conf.global_settings import *
#==============================================================================
# ==============================================================================
# Calculation of directories relative to the module location
#==============================================================================
# ==============================================================================
import os
import sys
import dpaste
@ -25,9 +25,9 @@ else:
# ignored by the repository).
VAR_ROOT = os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'conf', 'local')
#==============================================================================
# ==============================================================================
# Generic Django project settings
#==============================================================================
# ==============================================================================
DEBUG = False
@ -41,9 +41,9 @@ SECRET_KEY = ''
ALLOWED_HOSTS = ['*']
#==============================================================================
# ==============================================================================
# I18N
#==============================================================================
# ==============================================================================
USE_I18N = True
USE_L10N = False
@ -51,19 +51,15 @@ USE_L10N = False
LANGUAGE_CODE = 'en'
LANGUAGES = (
('en', 'English'),
# ('de', 'German'),
# ('es', 'Spanish'),
# ('pt-br', 'Portugese (Brasil)'),
# ('fr', 'French'),
)
LOCALE_PATHS = (
os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'locale')),
)
# LOCALE_PATHS = (
# os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'locale')),
# )
#==============================================================================
# ==============================================================================
# Project URLS and media settings
#==============================================================================
# ==============================================================================
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
@ -87,9 +83,9 @@ LOGIN_URL = '/accounts/login/'
LOGOUT_URL = '/accounts/logout/'
LOGIN_REDIRECT_URL = '/'
#==============================================================================
# ==============================================================================
# Templates
#==============================================================================
# ==============================================================================
MIDDLEWARE = [
'django.middleware.csrf.CsrfViewMiddleware',
@ -123,24 +119,24 @@ INSTALLED_APPS = [
'dpaste.apps.dpasteAppConfig',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'dev.db',
'USER': '',
'PASSWORD': '',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': 'dev.db',
# 'USER': '',
# 'PASSWORD': '',
# }
# }
#==============================================================================
# ==============================================================================
# App specific settings
#==============================================================================
# ==============================================================================
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_BROWSER_XSS_FILTER =True
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
CSP_DEFAULT_SRC = ("'none'",)

View file

@ -230,9 +230,9 @@ class APIView(View):
return HttpResponseBadRequest('Invalid lexer "%s" given. Valid lexers are: %s' % (
lexer, ', '.join(highlight.LEXER_KEYS)))
# No lexer is given, but we have a filename, try to get the lexer out of it.
# In case Pygments cannot determine the lexer of the filename, we fallback
# to 'plain' code.
# No lexer is given, but we have a filename, try to get the lexer
# out of it. In case Pygments cannot determine the lexer of the
# filename, we fallback to 'plain' code.
if not lexer and filename:
try:
lexer_cls = get_lexer_for_filename(filename)
@ -242,9 +242,10 @@ class APIView(View):
if expires:
expire_options = [str(i) for i in dict(config.EXPIRE_CHOICES).keys()]
if not expires in expire_options:
return HttpResponseBadRequest('Invalid expire choice "{}" given. '
'Valid values are: {}'.format(expires, ', '.join(expire_options)))
if expires not in expire_options:
return HttpResponseBadRequest(
'Invalid expire choice "{}" given. Valid values are: {}'.format(
expires, ', '.join(expire_options)))
expires, expire_type = get_expire_values(expires)
else:
expires = datetime.datetime.now() + datetime.timedelta(seconds=60 * 60 * 24)