blob: df70915bd665f21d5c838ffa4fddbfd3010eb862 [file] [log] [blame]
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -08001"""Django settings for frontend project.
2"""
mblighe8819cd2008-02-15 16:48:40 +00003
showarde90eb5e2008-07-25 20:54:21 +00004import os
mbligh437c3a62008-04-07 00:42:57 +00005import common
6from autotest_lib.client.common_lib import global_config
showardfa7ef632008-03-26 00:02:30 +00007
Dale Curtis74a314b2011-06-23 14:55:46 -07008c = global_config.global_config
9_section = 'AUTOTEST_WEB'
10
11DEBUG = c.get_config_value(_section, "sql_debug_mode", type=bool, default=False)
12TEMPLATE_DEBUG = c.get_config_value(_section, "template_debug_mode", type=bool,
13 default=False)
mblighe8819cd2008-02-15 16:48:40 +000014
15FULL_ADMIN = False
16
17ADMINS = (
18 # ('Your Name', 'your_email@domain.com'),
19)
20
21MANAGERS = ADMINS
22
Jakob Juelich3270e182014-10-13 10:00:43 -070023def _get_config(config_key, default=None):
Jakob Juelicha2040882014-10-13 09:49:24 -070024 """Retrieves a global config value for the specified key.
25
26 @param config_key: The string key associated with the desired config value.
Jakob Juelich3270e182014-10-13 10:00:43 -070027 @param default: The default value to return if an existing one cannot be
28 found.
Jakob Juelicha2040882014-10-13 09:49:24 -070029
Jakob Juelich3270e182014-10-13 10:00:43 -070030 @return The config value, as returned by
31 global_config.global_config.get_config_value().
Jakob Juelicha2040882014-10-13 09:49:24 -070032 """
Jakob Juelich3270e182014-10-13 10:00:43 -070033 return c.get_config_value(_section, config_key, default=default)
Jakob Juelicha2040882014-10-13 09:49:24 -070034
Jakob Juelich3270e182014-10-13 10:00:43 -070035AUTOTEST_DEFAULT = {
36 'ENGINE': 'autotest_lib.frontend.db.backends.afe',
37 'PORT': '',
38 'HOST': _get_config("host"),
39 'NAME': _get_config("database"),
40 'USER': _get_config("user"),
41 'PASSWORD': _get_config("password", default=''),
42 'READONLY_HOST': _get_config("readonly_host", default=_get_config("host")),
43 'READONLY_USER': _get_config("readonly_user", default=_get_config("user")),
44}
Alex Miller47d61282013-04-17 13:53:58 -070045
46ALLOWED_HOSTS = '*'
showard09096d82008-07-07 23:20:49 +000047
Jakob Juelich3270e182014-10-13 10:00:43 -070048if AUTOTEST_DEFAULT['READONLY_USER'] != AUTOTEST_DEFAULT['USER']:
49 AUTOTEST_DEFAULT['READONLY_PASSWORD'] = _get_config("readonly_password",
50 default='')
51else:
52 AUTOTEST_DEFAULT['READONLY_PASSWORD'] = AUTOTEST_DEFAULT['PASSWORD']
Mike Truty3536b982011-08-29 13:05:16 -070053
Jakob Juelich3270e182014-10-13 10:00:43 -070054DATABASES = {'default': AUTOTEST_DEFAULT}
mblighe8819cd2008-02-15 16:48:40 +000055
56# prefix applied to all URLs - useful if requests are coming through apache,
57# and you need this app to coexist with others
58URL_PREFIX = 'afe/server/'
showard250d84d2010-01-12 21:59:48 +000059TKO_URL_PREFIX = 'new_tko/server/'
Mike Trutyddd44b22011-04-14 15:38:56 -070060CROSCHART_URL_PREFIX = 'croschart/server/'
mblighe8819cd2008-02-15 16:48:40 +000061
62# Local time zone for this installation. Choices can be found here:
63# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
64# although not all variations may be possible on all operating systems.
65# If running in a Windows environment this must be set to the same as your
66# system time zone.
67TIME_ZONE = 'America/Los_Angeles'
68
69# Language code for this installation. All choices can be found here:
70# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
71# http://blogs.law.harvard.edu/tech/stories/storyReader$15
72LANGUAGE_CODE = 'en-us'
73
74SITE_ID = 1
75
76# If you set this to False, Django will make some optimizations so as not
77# to load the internationalization machinery.
78USE_I18N = True
79
80# Absolute path to the directory that holds media.
81# Example: "/home/media/media.lawrence.com/"
82MEDIA_ROOT = ''
83
84# URL that handles the media served from MEDIA_ROOT.
85# Example: "http://media.lawrence.com"
86MEDIA_URL = ''
87
Jiaxi Luoc342f9f2014-05-19 16:22:03 -070088# URL prefix of static file. Only used by the admin interface.
89STATIC_URL = '/' + URL_PREFIX + 'admin/'
90
mblighe8819cd2008-02-15 16:48:40 +000091# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
92# trailing slash.
93# Examples: "http://foo.com/media/", "/media/".
94ADMIN_MEDIA_PREFIX = '/media/'
95
Jakob Juelich3270e182014-10-13 10:00:43 -070096# Make this unique, and don't share it with anybody.
97SECRET_KEY = 'pn-t15u(epetamdflb%dqaaxw+5u&2#0u-jah70w1l*_9*)=n7'
98
mblighe8819cd2008-02-15 16:48:40 +000099# List of callables that know how to import templates from various sources.
100TEMPLATE_LOADERS = (
Mike Trutyf5814ba2011-08-29 18:27:46 -0700101 'django.template.loaders.filesystem.Loader',
102 'django.template.loaders.app_directories.Loader',
103# 'django.template.loaders.eggs.Loader',
mblighe8819cd2008-02-15 16:48:40 +0000104)
105
106MIDDLEWARE_CLASSES = (
107 'django.middleware.common.CommonMiddleware',
108 'django.contrib.sessions.middleware.SessionMiddleware',
109 'frontend.apache_auth.ApacheAuthMiddleware',
110 'django.contrib.auth.middleware.AuthenticationMiddleware',
111 'django.middleware.doc.XViewMiddleware',
Jiaxi Luo76a11d32014-05-08 19:03:28 -0700112 'django.contrib.messages.middleware.MessageMiddleware',
showard00b167c2010-02-03 20:29:45 +0000113 'frontend.shared.json_html_formatter.JsonToHtmlMiddleware',
mblighe8819cd2008-02-15 16:48:40 +0000114)
115
116ROOT_URLCONF = 'frontend.urls'
117
118TEMPLATE_DIRS = (
119 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
120 # Always use forward slashes, even on Windows.
121 # Don't forget to use absolute paths, not relative paths.
showard37c7fe62008-07-24 16:35:02 +0000122
Mike Trutyddd44b22011-04-14 15:38:56 -0700123 os.path.abspath(os.path.dirname(__file__) + '/templates'),
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -0800124 os.path.abspath(os.path.dirname(__file__) + '/croschart/templates'),
125 os.path.abspath(os.path.dirname(__file__) + '/perf-dashboard/templates')
mblighe8819cd2008-02-15 16:48:40 +0000126)
127
128INSTALLED_APPS = (
129 'frontend.afe',
showard250d84d2010-01-12 21:59:48 +0000130 'frontend.tko',
Mike Trutyddd44b22011-04-14 15:38:56 -0700131 'frontend.croschart',
mblighe8819cd2008-02-15 16:48:40 +0000132 'django.contrib.admin',
133 'django.contrib.auth',
134 'django.contrib.contenttypes',
135 'django.contrib.sessions',
136 'django.contrib.sites',
137)
138
mblighe8819cd2008-02-15 16:48:40 +0000139AUTHENTICATION_BACKENDS = (
140 'frontend.apache_auth.SimpleAuthBackend',
141)
Scott Zawalski38428ef2012-07-10 15:29:10 -0400142# TODO(scottz): Temporary addition until time can be spent untangling middleware
143# session crosbug.com/31608
144SESSION_COOKIE_AGE = 1200
Aviv Keshet62cf0472013-05-04 22:40:17 -0700145
146AUTOTEST_CREATE_ADMIN_GROUPS = True