Configuration

This section describes any settings which are specific to IAR Stats Gatherer

Specifying the database

The default settings.py file contains a facility to configure the database by means of environment variables. A variable with a name of the form DJANGO_DB_<key> will be used to set the DATABASES['default'][<key>] setting. So, for example, one could set the location of the sqlite database by setting the DJANGO_DB_NAME environment variable or one could change the backend by setting DJANGO_DB_BACKEND.

Default settings

The default settings are given in the gatherstats_project.settings.base module:

gatherstats_project.settings.base.BASE_DIR = '/usr/src/app/gatherstats_project'

Base directory containing the project. Build paths inside the project via os.path.join(BASE_DIR, ...).

gatherstats_project.settings.base.SECRET_KEY = 'this-key-is-not-secret-in-any-meaningful-way'

The Django secret key is by default set from the environment. If omitted, a system check will complain.

gatherstats_project.settings.base.DEBUG = True

SECURITY WARNING: don’t run with debug turned on in production!

gatherstats_project.settings.base.ALLOWED_HOSTS = []

By default, no hosts are allowed.

gatherstats_project.settings.base.INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'automationcommon', 'ucamwebauth', 'gatherstats']

Installed applications

gatherstats_project.settings.base.MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Installed middleware

gatherstats_project.settings.base.ROOT_URLCONF = 'gatherstats_project.urls'

Root URL patterns

gatherstats_project.settings.base.TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}}]

Template loading

gatherstats_project.settings.base.WSGI_APPLICATION = 'gatherstats_project.wsgi.application'

WSGI

gatherstats_project.settings.base.DATABASES = {'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.postgresql', 'HOST': 'iar-gatherstats-db', 'NAME': 'iar-gatherstats', 'OPTIONS': {}, 'PASSWORD': 'iar-gatherstats_password', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': 'postgres'}}

Database configuration. The default settings allow configuration of the database from environment variables. An environment variable named DJANGO_DB_<key> will override the DATABASES['default'][<key>] setting.

gatherstats_project.settings.base.AUTH_PASSWORD_VALIDATORS = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'}]

Password validation

gatherstats_project.settings.base.LANGUAGE_CODE = 'en-gb'

Internationalization

gatherstats_project.settings.base.TIME_ZONE = 'UTC'

Internationalization

gatherstats_project.settings.base.USE_I18N = True

Internationalization

gatherstats_project.settings.base.USE_L10N = True

Internationalization

gatherstats_project.settings.base.USE_TZ = True

Internationalization

gatherstats_project.settings.base.STATIC_URL = '/static/'

Static files (CSS, JavaScript, Images)

gatherstats_project.settings.base.AUTHENTICATION_BACKENDS = ['ucamwebauth.backends.RavenAuthBackend', 'django.contrib.auth.backends.ModelBackend']

Authentication backends

gatherstats_project.settings.base.UCAMWEBAUTH_CREATE_USER = True

Allow the autocreation of users who have been successfully authenticated by Raven but do not exist in the local database.

gatherstats_project.settings.base.UCAMWEBAUTH_LOGOUT_REDIRECT = 'https://raven.cam.ac.uk/auth/logout.html'

Redirect to this URL on log out

gatherstats_project.settings.base.UCAMWEBAUTH_NOT_CURRENT = False

Allow members who are not current members to log in?