Dennis Jeffrey | b95ba5a | 2012-11-12 17:55:18 -0800 | [diff] [blame] | 1 | """Django settings for frontend project. |
| 2 | """ |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 3 | |
showard | e90eb5e | 2008-07-25 20:54:21 +0000 | [diff] [blame] | 4 | import os |
mbligh | 437c3a6 | 2008-04-07 00:42:57 +0000 | [diff] [blame] | 5 | import common |
| 6 | from autotest_lib.client.common_lib import global_config |
showard | fa7ef63 | 2008-03-26 00:02:30 +0000 | [diff] [blame] | 7 | |
Dale Curtis | 74a314b | 2011-06-23 14:55:46 -0700 | [diff] [blame] | 8 | c = global_config.global_config |
| 9 | _section = 'AUTOTEST_WEB' |
| 10 | |
| 11 | DEBUG = c.get_config_value(_section, "sql_debug_mode", type=bool, default=False) |
| 12 | TEMPLATE_DEBUG = c.get_config_value(_section, "template_debug_mode", type=bool, |
| 13 | default=False) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 14 | |
| 15 | FULL_ADMIN = False |
| 16 | |
| 17 | ADMINS = ( |
| 18 | # ('Your Name', 'your_email@domain.com'), |
| 19 | ) |
| 20 | |
| 21 | MANAGERS = ADMINS |
| 22 | |
Mike Truty | 3536b98 | 2011-08-29 13:05:16 -0700 | [diff] [blame] | 23 | def _get_config(config_key, default=None): |
Dennis Jeffrey | b95ba5a | 2012-11-12 17:55:18 -0800 | [diff] [blame] | 24 | """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 Curtis | 8adf789 | 2011-09-08 16:13:36 -0700 | [diff] [blame] | 33 | return c.get_config_value(_section, config_key, default=default) |
showard | fa7ef63 | 2008-03-26 00:02:30 +0000 | [diff] [blame] | 34 | |
Mike Truty | 3536b98 | 2011-08-29 13:05:16 -0700 | [diff] [blame] | 35 | AUTOTEST_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 Miller | 47d6128 | 2013-04-17 13:53:58 -0700 | [diff] [blame] | 43 | 'READONLY_USER': _get_config("readonly_user", default=_get_config("user")), |
| 44 | } |
| 45 | |
| 46 | ALLOWED_HOSTS = '*' |
showard | 09096d8 | 2008-07-07 23:20:49 +0000 | [diff] [blame] | 47 | |
Mike Truty | 3536b98 | 2011-08-29 13:05:16 -0700 | [diff] [blame] | 48 | if AUTOTEST_DEFAULT['READONLY_USER'] != AUTOTEST_DEFAULT['USER']: |
| 49 | AUTOTEST_DEFAULT['READONLY_PASSWORD'] = _get_config("readonly_password", |
| 50 | default='') |
showard | 7a37db1 | 2009-01-08 23:31:08 +0000 | [diff] [blame] | 51 | else: |
Mike Truty | 3536b98 | 2011-08-29 13:05:16 -0700 | [diff] [blame] | 52 | AUTOTEST_DEFAULT['READONLY_PASSWORD'] = AUTOTEST_DEFAULT['PASSWORD'] |
| 53 | |
| 54 | DATABASES = {'default': AUTOTEST_DEFAULT} |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 55 | |
| 56 | # prefix applied to all URLs - useful if requests are coming through apache, |
| 57 | # and you need this app to coexist with others |
| 58 | URL_PREFIX = 'afe/server/' |
showard | 250d84d | 2010-01-12 21:59:48 +0000 | [diff] [blame] | 59 | TKO_URL_PREFIX = 'new_tko/server/' |
Mike Truty | ddd44b2 | 2011-04-14 15:38:56 -0700 | [diff] [blame] | 60 | CROSCHART_URL_PREFIX = 'croschart/server/' |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 61 | |
| 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. |
| 67 | TIME_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 |
| 72 | LANGUAGE_CODE = 'en-us' |
| 73 | |
| 74 | SITE_ID = 1 |
| 75 | |
| 76 | # If you set this to False, Django will make some optimizations so as not |
| 77 | # to load the internationalization machinery. |
| 78 | USE_I18N = True |
| 79 | |
| 80 | # Absolute path to the directory that holds media. |
| 81 | # Example: "/home/media/media.lawrence.com/" |
| 82 | MEDIA_ROOT = '' |
| 83 | |
| 84 | # URL that handles the media served from MEDIA_ROOT. |
| 85 | # Example: "http://media.lawrence.com" |
| 86 | MEDIA_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/". |
| 91 | ADMIN_MEDIA_PREFIX = '/media/' |
| 92 | |
| 93 | # Make this unique, and don't share it with anybody. |
| 94 | SECRET_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. |
| 97 | TEMPLATE_LOADERS = ( |
Mike Truty | f5814ba | 2011-08-29 18:27:46 -0700 | [diff] [blame] | 98 | 'django.template.loaders.filesystem.Loader', |
| 99 | 'django.template.loaders.app_directories.Loader', |
| 100 | # 'django.template.loaders.eggs.Loader', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 101 | ) |
| 102 | |
| 103 | MIDDLEWARE_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', |
showard | 00b167c | 2010-02-03 20:29:45 +0000 | [diff] [blame] | 109 | 'frontend.shared.json_html_formatter.JsonToHtmlMiddleware', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 110 | ) |
| 111 | |
| 112 | ROOT_URLCONF = 'frontend.urls' |
| 113 | |
| 114 | TEMPLATE_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. |
showard | 37c7fe6 | 2008-07-24 16:35:02 +0000 | [diff] [blame] | 118 | |
Mike Truty | ddd44b2 | 2011-04-14 15:38:56 -0700 | [diff] [blame] | 119 | os.path.abspath(os.path.dirname(__file__) + '/templates'), |
Dennis Jeffrey | b95ba5a | 2012-11-12 17:55:18 -0800 | [diff] [blame] | 120 | os.path.abspath(os.path.dirname(__file__) + '/croschart/templates'), |
| 121 | os.path.abspath(os.path.dirname(__file__) + '/perf-dashboard/templates') |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 122 | ) |
| 123 | |
| 124 | INSTALLED_APPS = ( |
| 125 | 'frontend.afe', |
showard | 250d84d | 2010-01-12 21:59:48 +0000 | [diff] [blame] | 126 | 'frontend.tko', |
Mike Truty | ddd44b2 | 2011-04-14 15:38:56 -0700 | [diff] [blame] | 127 | 'frontend.croschart', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 128 | 'django.contrib.admin', |
| 129 | 'django.contrib.auth', |
| 130 | 'django.contrib.contenttypes', |
| 131 | 'django.contrib.sessions', |
| 132 | 'django.contrib.sites', |
| 133 | ) |
| 134 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 135 | AUTHENTICATION_BACKENDS = ( |
| 136 | 'frontend.apache_auth.SimpleAuthBackend', |
| 137 | ) |
Scott Zawalski | 38428ef | 2012-07-10 15:29:10 -0400 | [diff] [blame] | 138 | # TODO(scottz): Temporary addition until time can be spent untangling middleware |
| 139 | # session crosbug.com/31608 |
| 140 | SESSION_COOKIE_AGE = 1200 |
Aviv Keshet | 62cf047 | 2013-05-04 22:40:17 -0700 | [diff] [blame] | 141 | |
| 142 | AUTOTEST_CREATE_ADMIN_GROUPS = True |