Dennis Jeffrey | b95ba5a | 2012-11-12 17:55:18 -0800 | [diff] [blame] | 1 | """Django settings for frontend project. |
Jakob Juelich | 8a764d1 | 2014-10-14 19:24:21 -0700 | [diff] [blame] | 2 | |
| 3 | Two databases are configured for the use with django here. One for tko tables, |
| 4 | which will always be the same database for all instances (the global database), |
| 5 | and one for everything else, which will be the same as the global database for |
| 6 | the master, but a local database for shards. |
| 7 | Additionally there is a third database connection for read only access to the |
| 8 | global database. |
| 9 | |
| 10 | This is implemented using a Django database router. |
| 11 | For more details on how the routing works, see db_router.py. |
Dennis Jeffrey | b95ba5a | 2012-11-12 17:55:18 -0800 | [diff] [blame] | 12 | """ |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 13 | |
mbligh | 437c3a6 | 2008-04-07 00:42:57 +0000 | [diff] [blame] | 14 | import common |
| 15 | from autotest_lib.client.common_lib import global_config |
Jakob Juelich | 934f0dc | 2014-10-14 18:21:13 -0700 | [diff] [blame] | 16 | from autotest_lib.frontend import database_settings_helper |
showard | fa7ef63 | 2008-03-26 00:02:30 +0000 | [diff] [blame] | 17 | |
Dale Curtis | 74a314b | 2011-06-23 14:55:46 -0700 | [diff] [blame] | 18 | c = global_config.global_config |
| 19 | _section = 'AUTOTEST_WEB' |
| 20 | |
| 21 | DEBUG = c.get_config_value(_section, "sql_debug_mode", type=bool, default=False) |
| 22 | TEMPLATE_DEBUG = c.get_config_value(_section, "template_debug_mode", type=bool, |
| 23 | default=False) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 24 | |
| 25 | FULL_ADMIN = False |
| 26 | |
| 27 | ADMINS = ( |
| 28 | # ('Your Name', 'your_email@domain.com'), |
| 29 | ) |
| 30 | |
| 31 | MANAGERS = ADMINS |
| 32 | |
Jakob Juelich | 934f0dc | 2014-10-14 18:21:13 -0700 | [diff] [blame] | 33 | AUTOTEST_DEFAULT = database_settings_helper.get_default_db_config() |
Jakob Juelich | 7bef841 | 2014-10-14 19:11:54 -0700 | [diff] [blame] | 34 | AUTOTEST_GLOBAL = database_settings_helper.get_global_db_config() |
| 35 | AUTOTEST_READONLY = database_settings_helper.get_readonly_db_config() |
Dan Shi | 9a535c9 | 2014-11-24 08:52:40 -0800 | [diff] [blame] | 36 | AUTOTEST_SERVER = database_settings_helper.get_server_db_config() |
Alex Miller | 47d6128 | 2013-04-17 13:53:58 -0700 | [diff] [blame] | 37 | |
| 38 | ALLOWED_HOSTS = '*' |
showard | 09096d8 | 2008-07-07 23:20:49 +0000 | [diff] [blame] | 39 | |
Jakob Juelich | 7bef841 | 2014-10-14 19:11:54 -0700 | [diff] [blame] | 40 | DATABASES = {'default': AUTOTEST_DEFAULT, |
Jakob Juelich | 8a764d1 | 2014-10-14 19:24:21 -0700 | [diff] [blame] | 41 | 'global': AUTOTEST_GLOBAL, |
Dan Shi | 9a535c9 | 2014-11-24 08:52:40 -0800 | [diff] [blame] | 42 | 'readonly': AUTOTEST_READONLY, |
| 43 | 'server': AUTOTEST_SERVER,} |
Mike Truty | 3536b98 | 2011-08-29 13:05:16 -0700 | [diff] [blame] | 44 | |
Jakob Juelich | 934f0dc | 2014-10-14 18:21:13 -0700 | [diff] [blame] | 45 | # Have to set SECRET_KEY before importing connections because of this bug: |
| 46 | # https://code.djangoproject.com/ticket/20704 |
| 47 | # TODO: Order this again after an upgrade to Django 1.6 or higher. |
| 48 | # Make this unique, and don't share it with anybody. |
| 49 | SECRET_KEY = 'pn-t15u(epetamdflb%dqaaxw+5u&2#0u-jah70w1l*_9*)=n7' |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 50 | |
Jakob Juelich | 8a764d1 | 2014-10-14 19:24:21 -0700 | [diff] [blame] | 51 | # Do not do this here or from the router, or most unit tests will fail. |
| 52 | # from django.db import connection |
| 53 | |
| 54 | DATABASE_ROUTERS = ['autotest_lib.frontend.db_router.Router'] |
| 55 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 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/' |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 60 | |
| 61 | # Local time zone for this installation. Choices can be found here: |
| 62 | # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE |
| 63 | # although not all variations may be possible on all operating systems. |
| 64 | # If running in a Windows environment this must be set to the same as your |
| 65 | # system time zone. |
| 66 | TIME_ZONE = 'America/Los_Angeles' |
| 67 | |
| 68 | # Language code for this installation. All choices can be found here: |
| 69 | # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes |
| 70 | # http://blogs.law.harvard.edu/tech/stories/storyReader$15 |
| 71 | LANGUAGE_CODE = 'en-us' |
| 72 | |
| 73 | SITE_ID = 1 |
| 74 | |
| 75 | # If you set this to False, Django will make some optimizations so as not |
| 76 | # to load the internationalization machinery. |
| 77 | USE_I18N = True |
| 78 | |
| 79 | # Absolute path to the directory that holds media. |
| 80 | # Example: "/home/media/media.lawrence.com/" |
| 81 | MEDIA_ROOT = '' |
| 82 | |
| 83 | # URL that handles the media served from MEDIA_ROOT. |
| 84 | # Example: "http://media.lawrence.com" |
| 85 | MEDIA_URL = '' |
| 86 | |
Jiaxi Luo | c342f9f | 2014-05-19 16:22:03 -0700 | [diff] [blame] | 87 | # URL prefix of static file. Only used by the admin interface. |
| 88 | STATIC_URL = '/' + URL_PREFIX + 'admin/' |
| 89 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 90 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a |
| 91 | # trailing slash. |
| 92 | # Examples: "http://foo.com/media/", "/media/". |
| 93 | ADMIN_MEDIA_PREFIX = '/media/' |
| 94 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 95 | # List of callables that know how to import templates from various sources. |
| 96 | TEMPLATE_LOADERS = ( |
Mike Truty | f5814ba | 2011-08-29 18:27:46 -0700 | [diff] [blame] | 97 | 'django.template.loaders.filesystem.Loader', |
| 98 | 'django.template.loaders.app_directories.Loader', |
| 99 | # 'django.template.loaders.eggs.Loader', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 100 | ) |
| 101 | |
| 102 | MIDDLEWARE_CLASSES = ( |
| 103 | 'django.middleware.common.CommonMiddleware', |
| 104 | 'django.contrib.sessions.middleware.SessionMiddleware', |
| 105 | 'frontend.apache_auth.ApacheAuthMiddleware', |
| 106 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 107 | 'django.middleware.doc.XViewMiddleware', |
Jiaxi Luo | 76a11d3 | 2014-05-08 19:03:28 -0700 | [diff] [blame] | 108 | 'django.contrib.messages.middleware.MessageMiddleware', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 109 | ) |
| 110 | |
| 111 | ROOT_URLCONF = 'frontend.urls' |
| 112 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 113 | INSTALLED_APPS = ( |
| 114 | 'frontend.afe', |
showard | 250d84d | 2010-01-12 21:59:48 +0000 | [diff] [blame] | 115 | 'frontend.tko', |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 116 | 'django.contrib.admin', |
| 117 | 'django.contrib.auth', |
| 118 | 'django.contrib.contenttypes', |
| 119 | 'django.contrib.sessions', |
| 120 | 'django.contrib.sites', |
| 121 | ) |
| 122 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 123 | AUTHENTICATION_BACKENDS = ( |
| 124 | 'frontend.apache_auth.SimpleAuthBackend', |
| 125 | ) |
Scott Zawalski | 38428ef | 2012-07-10 15:29:10 -0400 | [diff] [blame] | 126 | # TODO(scottz): Temporary addition until time can be spent untangling middleware |
| 127 | # session crosbug.com/31608 |
| 128 | SESSION_COOKIE_AGE = 1200 |
Aviv Keshet | 62cf047 | 2013-05-04 22:40:17 -0700 | [diff] [blame] | 129 | |
Dan Shi | 9a535c9 | 2014-11-24 08:52:40 -0800 | [diff] [blame] | 130 | AUTOTEST_CREATE_ADMIN_GROUPS = True |