Skip to content

Commit

Permalink
Further improve settings
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed May 16, 2015
1 parent f6e8b0e commit 73169b7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 32 deletions.
28 changes: 28 additions & 0 deletions doc/admin/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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
---------------

Expand Down Expand Up @@ -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
---------------

Expand Down
2 changes: 0 additions & 2 deletions src/pretix/local_settings.py

This file was deleted.

82 changes: 52 additions & 30 deletions src/pretix/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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')

Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -194,8 +221,3 @@
},
},
}

try:
from .local_settings import * # NOQA
except ImportError:
pass

0 comments on commit 73169b7

Please sign in to comment.