blob: 79df5aecefcb3d5832ecc2d9475cc9b585cf8fa0 [file] [log] [blame]
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -08001"""Django settings for frontend project.
Jakob Juelich8a764d12014-10-14 19:24:21 -07002
3Two databases are configured for the use with django here. One for tko tables,
4which will always be the same database for all instances (the global database),
5and one for everything else, which will be the same as the global database for
6the master, but a local database for shards.
7Additionally there is a third database connection for read only access to the
8global database.
9
10This is implemented using a Django database router.
11For more details on how the routing works, see db_router.py.
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -080012"""
mblighe8819cd2008-02-15 16:48:40 +000013
showarde90eb5e2008-07-25 20:54:21 +000014import os
mbligh437c3a62008-04-07 00:42:57 +000015import common
16from autotest_lib.client.common_lib import global_config
Jakob Juelich934f0dc2014-10-14 18:21:13 -070017from autotest_lib.frontend import database_settings_helper
showardfa7ef632008-03-26 00:02:30 +000018
Dale Curtis74a314b2011-06-23 14:55:46 -070019c = global_config.global_config
20_section = 'AUTOTEST_WEB'
21
22DEBUG = c.get_config_value(_section, "sql_debug_mode", type=bool, default=False)
23TEMPLATE_DEBUG = c.get_config_value(_section, "template_debug_mode", type=bool,
24 default=False)
mblighe8819cd2008-02-15 16:48:40 +000025
26FULL_ADMIN = False
27
28ADMINS = (
29 # ('Your Name', 'your_email@domain.com'),
30)
31
32MANAGERS = ADMINS
33
Jakob Juelich934f0dc2014-10-14 18:21:13 -070034AUTOTEST_DEFAULT = database_settings_helper.get_default_db_config()
Jakob Juelich7bef8412014-10-14 19:11:54 -070035AUTOTEST_GLOBAL = database_settings_helper.get_global_db_config()
36AUTOTEST_READONLY = database_settings_helper.get_readonly_db_config()
Dan Shi9a535c92014-11-24 08:52:40 -080037AUTOTEST_SERVER = database_settings_helper.get_server_db_config()
Alex Miller47d61282013-04-17 13:53:58 -070038
39ALLOWED_HOSTS = '*'
showard09096d82008-07-07 23:20:49 +000040
Jakob Juelich7bef8412014-10-14 19:11:54 -070041DATABASES = {'default': AUTOTEST_DEFAULT,
Jakob Juelich8a764d12014-10-14 19:24:21 -070042 'global': AUTOTEST_GLOBAL,
Dan Shi9a535c92014-11-24 08:52:40 -080043 'readonly': AUTOTEST_READONLY,
44 'server': AUTOTEST_SERVER,}
Mike Truty3536b982011-08-29 13:05:16 -070045
Jakob Juelich934f0dc2014-10-14 18:21:13 -070046# Have to set SECRET_KEY before importing connections because of this bug:
47# https://code.djangoproject.com/ticket/20704
48# TODO: Order this again after an upgrade to Django 1.6 or higher.
49# Make this unique, and don't share it with anybody.
50SECRET_KEY = 'pn-t15u(epetamdflb%dqaaxw+5u&2#0u-jah70w1l*_9*)=n7'
mblighe8819cd2008-02-15 16:48:40 +000051
Jakob Juelich8a764d12014-10-14 19:24:21 -070052# Do not do this here or from the router, or most unit tests will fail.
53# from django.db import connection
54
55DATABASE_ROUTERS = ['autotest_lib.frontend.db_router.Router']
56
mblighe8819cd2008-02-15 16:48:40 +000057# prefix applied to all URLs - useful if requests are coming through apache,
58# and you need this app to coexist with others
59URL_PREFIX = 'afe/server/'
showard250d84d2010-01-12 21:59:48 +000060TKO_URL_PREFIX = 'new_tko/server/'
Mike Trutyddd44b22011-04-14 15:38:56 -070061CROSCHART_URL_PREFIX = 'croschart/server/'
mblighe8819cd2008-02-15 16:48:40 +000062
63# Local time zone for this installation. Choices can be found here:
64# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
65# although not all variations may be possible on all operating systems.
66# If running in a Windows environment this must be set to the same as your
67# system time zone.
68TIME_ZONE = 'America/Los_Angeles'
69
70# Language code for this installation. All choices can be found here:
71# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
72# http://blogs.law.harvard.edu/tech/stories/storyReader$15
73LANGUAGE_CODE = 'en-us'
74
75SITE_ID = 1
76
77# If you set this to False, Django will make some optimizations so as not
78# to load the internationalization machinery.
79USE_I18N = True
80
81# Absolute path to the directory that holds media.
82# Example: "/home/media/media.lawrence.com/"
83MEDIA_ROOT = ''
84
85# URL that handles the media served from MEDIA_ROOT.
86# Example: "http://media.lawrence.com"
87MEDIA_URL = ''
88
Jiaxi Luoc342f9f2014-05-19 16:22:03 -070089# URL prefix of static file. Only used by the admin interface.
90STATIC_URL = '/' + URL_PREFIX + 'admin/'
91
mblighe8819cd2008-02-15 16:48:40 +000092# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
93# trailing slash.
94# Examples: "http://foo.com/media/", "/media/".
95ADMIN_MEDIA_PREFIX = '/media/'
96
mblighe8819cd2008-02-15 16:48:40 +000097# List of callables that know how to import templates from various sources.
98TEMPLATE_LOADERS = (
Mike Trutyf5814ba2011-08-29 18:27:46 -070099 'django.template.loaders.filesystem.Loader',
100 'django.template.loaders.app_directories.Loader',
101# 'django.template.loaders.eggs.Loader',
mblighe8819cd2008-02-15 16:48:40 +0000102)
103
104MIDDLEWARE_CLASSES = (
105 'django.middleware.common.CommonMiddleware',
106 'django.contrib.sessions.middleware.SessionMiddleware',
107 'frontend.apache_auth.ApacheAuthMiddleware',
108 'django.contrib.auth.middleware.AuthenticationMiddleware',
109 'django.middleware.doc.XViewMiddleware',
Jiaxi Luo76a11d32014-05-08 19:03:28 -0700110 'django.contrib.messages.middleware.MessageMiddleware',
showard00b167c2010-02-03 20:29:45 +0000111 'frontend.shared.json_html_formatter.JsonToHtmlMiddleware',
mblighe8819cd2008-02-15 16:48:40 +0000112)
113
114ROOT_URLCONF = 'frontend.urls'
115
116TEMPLATE_DIRS = (
117 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
118 # Always use forward slashes, even on Windows.
119 # Don't forget to use absolute paths, not relative paths.
showard37c7fe62008-07-24 16:35:02 +0000120
Mike Trutyddd44b22011-04-14 15:38:56 -0700121 os.path.abspath(os.path.dirname(__file__) + '/templates'),
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -0800122 os.path.abspath(os.path.dirname(__file__) + '/croschart/templates'),
123 os.path.abspath(os.path.dirname(__file__) + '/perf-dashboard/templates')
mblighe8819cd2008-02-15 16:48:40 +0000124)
125
126INSTALLED_APPS = (
127 'frontend.afe',
showard250d84d2010-01-12 21:59:48 +0000128 'frontend.tko',
Mike Trutyddd44b22011-04-14 15:38:56 -0700129 'frontend.croschart',
mblighe8819cd2008-02-15 16:48:40 +0000130 'django.contrib.admin',
131 'django.contrib.auth',
132 'django.contrib.contenttypes',
133 'django.contrib.sessions',
134 'django.contrib.sites',
135)
136
mblighe8819cd2008-02-15 16:48:40 +0000137AUTHENTICATION_BACKENDS = (
138 'frontend.apache_auth.SimpleAuthBackend',
139)
Scott Zawalski38428ef2012-07-10 15:29:10 -0400140# TODO(scottz): Temporary addition until time can be spent untangling middleware
141# session crosbug.com/31608
142SESSION_COOKIE_AGE = 1200
Aviv Keshet62cf0472013-05-04 22:40:17 -0700143
Dan Shi9a535c92014-11-24 08:52:40 -0800144AUTOTEST_CREATE_ADMIN_GROUPS = True