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

View file

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