diff --git a/doc/admin/config.rst b/doc/admin/config.rst index 73b6ab054c0..6423ecd33d8 100644 --- a/doc/admin/config.rst +++ b/doc/admin/config.rst @@ -25,7 +25,10 @@ Example:: instance_name=pretix.de global_registration=off site_url=http://localhost + scriptname=/presale/ currency=EUR + cookiedomain=.pretix.de + securecookie=on ``instance_name`` 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 event-bound accounts). Defaults to ``True``. +``scriptname`` + The path pretix runs at, if it does not run under its own subdomain. + ``site_url`` The installation's full URL, without a trailing slash. ``currency`` 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 --------------- @@ -102,11 +115,26 @@ Example:: [mail] 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`` The email address to set as ``From`` header in outgoing emails by the system. Default: ``pretix@localhost`` +``tls``, ``ssl`` + Use STARTTLS or SSL for the SMTP connection. Off by default. + Django settings --------------- diff --git a/src/pretix/local_settings.py b/src/pretix/local_settings.py deleted file mode 100644 index bb21042958c..00000000000 --- a/src/pretix/local_settings.py +++ /dev/null @@ -1,2 +0,0 @@ -EMAIL_PORT = 1025 -EMAIL_HOST = '127.0.0.1' diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 054265e888f..0c1d6850753 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -21,6 +21,8 @@ with open(SECRET_FILE, 'w') as f: f.write(SECRET_KEY) +# Adjustable settings + DEBUG = TEMPLATE_DEBUG = config.getboolean('django', 'debug', fallback=False) DATABASES = { @@ -43,8 +45,8 @@ PRETIX_INSTANCE_NAME = config.get('pretix', 'instance_name', fallback='pretix.de') 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') +FORCE_SCRIPT_NAME = config.get('pretix', 'scriptname', fallback=None) DEFAULT_CURRENCY = config.get('pretix', 'currency', fallback='EUR') @@ -53,7 +55,23 @@ LANGUAGE_CODE = config.get('locale', 'default', fallback='en') 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 = ( 'django.contrib.admin', @@ -91,24 +109,10 @@ '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' WSGI_APPLICATION = 'pretix.wsgi.application' - USE_I18N = True USE_L10N = True USE_TZ = True @@ -123,16 +127,42 @@ ('de', _('German')), ) - -# Authentication - AUTH_USER_MODEL = 'pretixbase.User' LOGIN_URL = '/login' LOGIN_URL_CONTROL = '/control/login' -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/dev/howto/static-files/ - +template_loaders = ( + '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 = ( 'django.contrib.staticfiles.finders.FileSystemFinder', @@ -157,9 +187,6 @@ 'JQUERY_URL': '' } - -# Pretix specific settings - INTERNAL_IPS = ('127.0.0.1', '::1') from django.contrib.messages import constants as messages # NOQA @@ -194,8 +221,3 @@ }, }, } - -try: - from .local_settings import * # NOQA -except ImportError: - pass