Further improve settings

This commit is contained in:
Raphael Michel
2015-05-16 11:02:50 +02:00
parent f6e8b0ea37
commit 73169b78b6
3 changed files with 79 additions and 31 deletions

View File

@@ -25,7 +25,10 @@ Example::
instance_name=pretix.de instance_name=pretix.de
global_registration=off global_registration=off
site_url=http://localhost site_url=http://localhost
scriptname=/presale/
currency=EUR currency=EUR
cookiedomain=.pretix.de
securecookie=on
``instance_name`` ``instance_name``
The name of this installation. Default: ``pretix.de`` The name of this installation. Default: ``pretix.de``
@@ -34,12 +37,22 @@ Example::
Whether or not this installation supports global user accounts (in addition to Whether or not this installation supports global user accounts (in addition to
event-bound accounts). Defaults to ``True``. event-bound accounts). Defaults to ``True``.
``scriptname``
The path pretix runs at, if it does not run under its own subdomain.
``site_url`` ``site_url``
The installation's full URL, without a trailing slash. The installation's full URL, without a trailing slash.
``currency`` ``currency``
The default currency as a three-letter code. Defaults to ``EUR``. The default currency as a three-letter code. Defaults to ``EUR``.
``cookiedomain``
The domain to be used for session cookies, csrf protection cookies and locale cookies.
Empty by default.
``securecookie``
Set the ``secure`` and ``httponly`` flags on session cookies. Off by default.
Locale settings Locale settings
--------------- ---------------
@@ -102,11 +115,26 @@ Example::
[mail] [mail]
from=hello@localhost from=hello@localhost
host=127.0.0.71
user=pretix
password=foobar
port=1025
tls=on
ssl=off
``host``, ``port``
The SMTP Host to connect to. Defaults to ``localhost`` and ``25``.
``user``, ``password``
The SMTP user data to use for the connection. Empty by default.
``from`` ``from``
The email address to set as ``From`` header in outgoing emails by the system. The email address to set as ``From`` header in outgoing emails by the system.
Default: ``pretix@localhost`` Default: ``pretix@localhost``
``tls``, ``ssl``
Use STARTTLS or SSL for the SMTP connection. Off by default.
Django settings Django settings
--------------- ---------------

View File

@@ -1,2 +0,0 @@
EMAIL_PORT = 1025
EMAIL_HOST = '127.0.0.1'

View File

@@ -21,6 +21,8 @@ else:
with open(SECRET_FILE, 'w') as f: with open(SECRET_FILE, 'w') as f:
f.write(SECRET_KEY) f.write(SECRET_KEY)
# Adjustable settings
DEBUG = TEMPLATE_DEBUG = config.getboolean('django', 'debug', fallback=False) DEBUG = TEMPLATE_DEBUG = config.getboolean('django', 'debug', fallback=False)
DATABASES = { DATABASES = {
@@ -43,8 +45,8 @@ MEDIA_ROOT = config.get('media', 'root', fallback='media')
PRETIX_INSTANCE_NAME = config.get('pretix', 'instance_name', fallback='pretix.de') PRETIX_INSTANCE_NAME = config.get('pretix', 'instance_name', fallback='pretix.de')
PRETIX_GLOBAL_REGISTRATION = config.getboolean('pretix', 'global_registration', fallback=True) PRETIX_GLOBAL_REGISTRATION = config.getboolean('pretix', 'global_registration', fallback=True)
MAIL_FROM = config.get('mail', 'from', fallback='pretix@localhost')
SITE_URL = config.get('pretix', 'url', fallback='http://localhost') SITE_URL = config.get('pretix', 'url', fallback='http://localhost')
FORCE_SCRIPT_NAME = config.get('pretix', 'scriptname', fallback=None)
DEFAULT_CURRENCY = config.get('pretix', 'currency', fallback='EUR') DEFAULT_CURRENCY = config.get('pretix', 'currency', fallback='EUR')
@@ -53,7 +55,23 @@ ALLOWED_HOSTS = config.get('django', 'hosts', fallback='localhost').split(',')
LANGUAGE_CODE = config.get('locale', 'default', fallback='en') LANGUAGE_CODE = config.get('locale', 'default', fallback='en')
TIME_ZONE = config.get('locale', 'timezone', fallback='UTC') TIME_ZONE = config.get('locale', 'timezone', fallback='UTC')
# Application definition MAIL_FROM = SERVER_EMAIL = DEFAULT_FROM_EMAIL = config.get(
'mail', 'from', fallback='pretix@localhost')
EMAIL_HOST = config.get('mail', 'host', fallback='localhost')
EMAIL_PORT = config.getint('mail', 'port', fallback=25)
EMAIL_HOST_USER = config.get('mail', 'user', fallback='')
EMAIL_HOST_PASSWORD = config.get('mail', 'password', fallback='')
SESSION_COOKIE_SECURE = SESSION_COOKIE_HTTPONLY = config.getboolean(
'pretix', 'securecookie', fallback=False)
LANGUAGE_COOKIE_DOMAIN = SESSION_COOKIE_DOMAIN = CSRF_COOKIE_DOMAIN = config.get(
'pretix', 'cookiedomain', fallback=None)
# Internal settings
SESSION_COOKIE_NAME = 'pretix_session'
LANGUAGE_COOKIE_NAME = 'pretix_language'
CSRF_COOKIE_NAME = 'pretix_csrftoken'
INSTALLED_APPS = ( INSTALLED_APPS = (
'django.contrib.admin', 'django.contrib.admin',
@@ -91,24 +109,10 @@ MIDDLEWARE_CLASSES = (
'pretix.base.middleware.LocaleMiddleware', 'pretix.base.middleware.LocaleMiddleware',
) )
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
'pretix.control.context.contextprocessor',
'pretix.presale.context.contextprocessor',
)
ROOT_URLCONF = 'pretix.urls' ROOT_URLCONF = 'pretix.urls'
WSGI_APPLICATION = 'pretix.wsgi.application' WSGI_APPLICATION = 'pretix.wsgi.application'
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True USE_TZ = True
@@ -123,16 +127,42 @@ LANGUAGES = (
('de', _('German')), ('de', _('German')),
) )
# Authentication
AUTH_USER_MODEL = 'pretixbase.User' AUTH_USER_MODEL = 'pretixbase.User'
LOGIN_URL = '/login' LOGIN_URL = '/login'
LOGIN_URL_CONTROL = '/control/login' LOGIN_URL_CONTROL = '/control/login'
# Static files (CSS, JavaScript, Images) template_loaders = (
# https://docs.djangoproject.com/en/dev/howto/static-files/ 'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
if DEBUG:
template_loaders = (
('django.template.loaders.cached.Loader', template_loaders),
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
"django.template.context_processors.request",
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'pretix.control.context.contextprocessor',
'pretix.presale.context.contextprocessor',
],
'loaders': template_loaders
},
},
]
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
@@ -157,9 +187,6 @@ DEBUG_TOOLBAR_CONFIG = {
'JQUERY_URL': '' 'JQUERY_URL': ''
} }
# Pretix specific settings
INTERNAL_IPS = ('127.0.0.1', '::1') INTERNAL_IPS = ('127.0.0.1', '::1')
from django.contrib.messages import constants as messages # NOQA from django.contrib.messages import constants as messages # NOQA
@@ -194,8 +221,3 @@ LOGGING = {
}, },
}, },
} }
try:
from .local_settings import * # NOQA
except ImportError:
pass