blob: efec9240ac9c172862095ce5f35dbaf3f42ada86 [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
Mike Truty3536b982011-08-29 13:05:16 -070023def _get_config(config_key, default=None):
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -080024 """Retrieves a global config value for the specified key.
25
26 @param config_key: The string key associated with the desired config value.
27 @param default: The default value to return if an existing one cannot be
28 found.
29
30 @return The config value, as returned by
31 global_config.global_config.get_config_value().
32 """
Dale Curtis8adf7892011-09-08 16:13:36 -070033 return c.get_config_value(_section, config_key, default=default)
showardfa7ef632008-03-26 00:02:30 +000034
Mike Truty3536b982011-08-29 13:05:16 -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")),
Alex Miller47d61282013-04-17 13:53:58 -070043 'READONLY_USER': _get_config("readonly_user", default=_get_config("user")),
44}
45
46ALLOWED_HOSTS = '*'
showard09096d82008-07-07 23:20:49 +000047
Mike Truty3536b982011-08-29 13:05:16 -070048if AUTOTEST_DEFAULT['READONLY_USER'] != AUTOTEST_DEFAULT['USER']:
49 AUTOTEST_DEFAULT['READONLY_PASSWORD'] = _get_config("readonly_password",
50 default='')
showard7a37db12009-01-08 23:31:08 +000051else:
Mike Truty3536b982011-08-29 13:05:16 -070052 AUTOTEST_DEFAULT['READONLY_PASSWORD'] = AUTOTEST_DEFAULT['PASSWORD']
53
54DATABASES = {'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
88# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
89# trailing slash.
90# Examples: "http://foo.com/media/", "/media/".
91ADMIN_MEDIA_PREFIX = '/media/'
92
93# Make this unique, and don't share it with anybody.
94SECRET_KEY = 'pn-t15u(epetamdflb%dqaaxw+5u&2#0u-jah70w1l*_9*)=n7'
95
96# List of callables that know how to import templates from various sources.
97TEMPLATE_LOADERS = (
Mike Trutyf5814ba2011-08-29 18:27:46 -070098 'django.template.loaders.filesystem.Loader',
99 'django.template.loaders.app_directories.Loader',
100# 'django.template.loaders.eggs.Loader',
mblighe8819cd2008-02-15 16:48:40 +0000101)
102
103MIDDLEWARE_CLASSES = (
104 'django.middleware.common.CommonMiddleware',
105 'django.contrib.sessions.middleware.SessionMiddleware',
106 'frontend.apache_auth.ApacheAuthMiddleware',
107 'django.contrib.auth.middleware.AuthenticationMiddleware',
108 'django.middleware.doc.XViewMiddleware',
showard00b167c2010-02-03 20:29:45 +0000109 'frontend.shared.json_html_formatter.JsonToHtmlMiddleware',
mblighe8819cd2008-02-15 16:48:40 +0000110)
111
112ROOT_URLCONF = 'frontend.urls'
113
114TEMPLATE_DIRS = (
115 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
116 # Always use forward slashes, even on Windows.
117 # Don't forget to use absolute paths, not relative paths.
showard37c7fe62008-07-24 16:35:02 +0000118
Mike Trutyddd44b22011-04-14 15:38:56 -0700119 os.path.abspath(os.path.dirname(__file__) + '/templates'),
Dennis Jeffreyb95ba5a2012-11-12 17:55:18 -0800120 os.path.abspath(os.path.dirname(__file__) + '/croschart/templates'),
121 os.path.abspath(os.path.dirname(__file__) + '/perf-dashboard/templates')
mblighe8819cd2008-02-15 16:48:40 +0000122)
123
124INSTALLED_APPS = (
125 'frontend.afe',
showard250d84d2010-01-12 21:59:48 +0000126 'frontend.tko',
Mike Trutyddd44b22011-04-14 15:38:56 -0700127 'frontend.croschart',
mblighe8819cd2008-02-15 16:48:40 +0000128 'django.contrib.admin',
129 'django.contrib.auth',
130 'django.contrib.contenttypes',
131 'django.contrib.sessions',
132 'django.contrib.sites',
133)
134
mblighe8819cd2008-02-15 16:48:40 +0000135AUTHENTICATION_BACKENDS = (
136 'frontend.apache_auth.SimpleAuthBackend',
137)
Scott Zawalski38428ef2012-07-10 15:29:10 -0400138# TODO(scottz): Temporary addition until time can be spent untangling middleware
139# session crosbug.com/31608
140SESSION_COOKIE_AGE = 1200
Aviv Keshet62cf0472013-05-04 22:40:17 -0700141
142AUTOTEST_CREATE_ADMIN_GROUPS = True