8c5ff75a733fa5c77ba93021c7a41e31c4bd47b8
[plstackapi.git] / planetstack / planetstack / settings.py
1 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
2 from django import VERSION as DJANGO_VERSION
3
4 # Django settings for planetstack project.
5 from config import Config
6 config = Config()
7
8 GEOIP_PATH = "/usr/share/GeoIP"
9  
10 DEBUG = True
11 TEMPLATE_DEBUG = DEBUG
12
13 ADMINS = (
14     # ('Your Name', 'your_email@example.com'),
15 )
16
17 LOGIN_REDIRECT_URL = '/admin/core/user'
18
19 MANAGERS = ADMINS
20
21 DATABASES = {
22     'default': {
23         'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
24         'NAME': config.db_name,                      # Or path to database file if using sqlite3.
25         # The following settings are not used with sqlite3:
26         'USER': config.db_user,
27         'PASSWORD': config.db_password,
28         'HOST': config.db_host,                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
29         'PORT': '',                      # Set to empty string for default.
30     }
31 }
32
33 AUTH_USER_MODEL = 'core.User'
34
35
36 # Hosts/domain names that are valid for this site; required if DEBUG is False
37 # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
38 ALLOWED_HOSTS = []
39
40 # Local time zone for this installation. Choices can be found here:
41 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
42 # although not all choices may be available on all operating systems.
43 # In a Windows environment this must be set to your system time zone.
44 TIME_ZONE = 'America/New_York'
45
46 # Language code for this installation. All choices can be found here:
47 # http://www.i18nguy.com/unicode/language-identifiers.html
48 LANGUAGE_CODE = 'en-us'
49
50 SITE_ID = 1
51
52 # If you set this to False, Django will make some optimizations so as not
53 # to load the internationalization machinery.
54 USE_I18N = True
55
56 # If you set this to False, Django will not format dates, numbers and
57 # calendars according to the current locale.
58 USE_L10N = True
59
60 # If you set this to False, Django will not use timezone-aware datetimes.
61 USE_TZ = True
62
63 # Absolute filesystem path to the directory that will hold user-uploaded files.
64 # Example: "/var/www/example.com/media/"
65 MEDIA_ROOT = '/var/www/html/files/'
66
67 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
68 # trailing slash.
69 # Examples: "http://example.com/media/", "http://media.example.com/"
70 MEDIA_URL = '/files/'
71
72 # Absolute path to the directory static files should be collected to.
73 # Don't put anything in this directory yourself; store your static files
74 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
75 # Example: "/var/www/example.com/static/"
76 STATIC_ROOT = ''
77
78 # URL prefix for static files.
79 # Example: "http://example.com/static/", "http://static.example.com/"
80 STATIC_URL = '/static/'
81
82 # Additional locations of static files
83 STATICFILES_DIRS = ( "/opt/planetstack/core/static/",
84     # Put strings here, like "/home/html/static" or "C:/www/django/static".
85     # Always use forward slashes, even on Windows.
86     # Don't forget to use absolute paths, not relative paths.
87 )
88
89 # List of finder classes that know how to find static files in
90 # various locations.
91 STATICFILES_FINDERS = (
92     'django.contrib.staticfiles.finders.FileSystemFinder',
93     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
94 #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
95 )
96
97 # Make this unique, and don't share it with anybody.
98 SECRET_KEY = 'i0=a)c7_#2)5m%k_fu#%53xap$tlqc+#&z5as+bl7&)(@be_f9'
99
100 # List of callables that know how to import templates from various sources.
101 TEMPLATE_LOADERS = (
102     'django.template.loaders.filesystem.Loader',
103     'django.template.loaders.app_directories.Loader',
104 #     'django.template.loaders.eggs.Loader',
105 )
106
107 MIDDLEWARE_CLASSES = (
108     'django.middleware.common.CommonMiddleware',
109     'django.contrib.sessions.middleware.SessionMiddleware',
110     'django.middleware.csrf.CsrfViewMiddleware',
111     'django.contrib.auth.middleware.AuthenticationMiddleware',
112     'django.contrib.messages.middleware.MessageMiddleware',
113     # Uncomment the next line for simple clickjacking protection:
114     # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
115 )
116
117 ROOT_URLCONF = 'planetstack.urls'
118
119 # Python dotted path to the WSGI application used by Django's runserver.
120 WSGI_APPLICATION = 'planetstack.wsgi.application'
121
122 TEMPLATE_DIRS = (
123     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
124     # Always use forward slashes, even on Windows.
125     # Don't forget to use absolute paths, not relative paths.
126     "/opt/planetstack/templates",
127 )
128
129 INSTALLED_APPS = (
130     'django.contrib.auth',
131     'django.contrib.contenttypes',
132     'django.contrib.sessions',
133 #    'django.contrib.sites',
134     'django.contrib.messages',
135     'django.contrib.staticfiles',
136     # Uncomment the next line to enable the admin:
137     'suit',
138     'django.contrib.admin',
139     # Uncomment the next line to enable admin documentation:
140     'django.contrib.admindocs',
141     'rest_framework',
142     'django_extensions',
143     'django_evolution',
144     'core',
145     'hpc',
146     'requestrouter',
147     'cassandra',
148     'kairos',
149     'nagios',
150     'syndicate',
151     'geoposition',
152 )
153
154 if DJANGO_VERSION[1]>=7:
155     # if django >= 1.7, then remove evolution and change the admin module
156     INSTALLED_APPS = list(INSTALLED_APPS)
157     INSTALLED_APPS[INSTALLED_APPS.index('django.contrib.admin')] = 'django.contrib.admin.apps.SimpleAdminConfig'
158     INSTALLED_APPS.remove('django_evolution')
159     INSTALLED_APPS = tuple(INSTALLED_APPS)
160
161 # Added for django-suit form 
162 TEMPLATE_CONTEXT_PROCESSORS = TCP + (
163     'django.core.context_processors.request',
164     'core.context_processors.planetstack',
165 )
166
167 # Django Suit configuration example
168 SUIT_CONFIG = {
169     # header
170     'ADMIN_NAME': 'OpenCloud',
171     # 'HEADER_DATE_FORMAT': 'l, j. F Y',
172     # 'HEADER_TIME_FORMAT': 'H:i',
173
174     # forms
175     #'SHOW_REQUIRED_ASTERISK': True,  # Default True
176     'CONFIRM_UNSAVED_CHANGES': True, # Default True
177
178     # menu
179     # 'SEARCH_URL': '/admin/auth/user/',
180     # 'MENU_ICONS': {
181     #    'sites': 'icon-leaf',
182     #    'auth': 'icon-lock',
183     # },
184     # 'MENU_OPEN_FIRST_CHILD': True, # Default True
185     'MENU_EXCLUDE': (
186          'auth.group',
187          'auth', 
188          'core.network',
189          'core.sliver',
190          'core.node',
191          'core.image',
192          'core.deploymentrole',
193          'core.siterole',
194          'core.slicerole',
195          'core.planetstackrole',
196          'core.networktemplate',
197          'core.networkparametertype',
198          'core.router',
199          'core.tag',
200          'core.account',
201          'core.invoice',
202          'core.serviceclass',
203     ),
204     'MENU': (
205         #{'app': 'core', 'icon':'icon-lock'},
206         #{'app': 'core', 'icon': 'icon-lock', 'models': ('core.site', 'core.deployment', 'core.service', 'core.slice', 'core.user', 'core.reservation', 'core.account', 'core.invoice', 'core.payment', 'core.usableobject')},
207         {'label': 'Deployments', 'icon':'icon-deployment', 'url': '/admin/core/deployment/'},
208         {'label': 'Sites', 'icon':'icon-site', 'url': '/admin/core/site/'},
209         {'label': 'Slices', 'icon':'icon-slice', 'url': '/admin/core/slice/'},
210         {'label': 'Users', 'icon':'icon-user', 'url': '/admin/core/user/'},
211         {'label': 'RequestRouter', 'icon':'icon-cog', 'app': 'requestrouter'},
212         {'label': 'HyperCache', 'icon':'icon-cog', 'app': 'hpc'},
213         {'label': 'Syndicate', 'icon':'icon-cog', 'app': 'syndicate'},
214         {'label': 'Cassandra', 'icon':'icon-cog', 'app': 'cassandra'},
215 #        {'label': 'KairosDB', 'icon':'icon-cog', 'app': 'kairos'},
216 #        {'label': 'Nagios', 'icon':'icon-cog', 'app': 'nagios'},
217
218         #{'label': 'Configured Services', 'icon':'icon-cog', 'models': [{'label': 'Content Delivery Network', 'app':'hpc'}]},
219     #     'sites',
220     #     {'app': 'auth', 'icon':'icon-lock', 'models': ('user', 'group')},
221     #     {'label': 'Support', 'icon':'icon-question-sign', 'url': '/support/'},
222     #   {'label': 'Settings', 'icon':'icon-cog', 'models': ('core.user', 'core.site')},
223     # ),
224     ),
225
226     # misc
227     # 'LIST_PER_PAGE': 15
228 }
229
230 # A sample logging configuration. The only tangible logging
231 # performed by this configuration is to send an email to
232 # the site admins on every HTTP 500 error when DEBUG=False.
233 # See http://docs.djangoproject.com/en/dev/topics/logging for
234 # more details on how to customize your logging configuration.
235 LOGGING = {
236     'version': 1,
237     'disable_existing_loggers': False,
238     'filters': {
239         'require_debug_false': {
240             '()': 'django.utils.log.RequireDebugFalse'
241         }
242     },
243     'handlers': {
244         'mail_admins': {
245             'level': 'ERROR',
246             'filters': ['require_debug_false'],
247             'class': 'django.utils.log.AdminEmailHandler'
248         }
249     },
250     'loggers': {
251         'django.request': {
252             'handlers': ['mail_admins'],
253             'level': 'ERROR',
254             'propagate': True,
255         },
256     }
257 }
258
259 BIGQUERY_TABLE = getattr(config, "bigquery_table", "demoevents")
260
261 DISABLE_MINIDASHBOARD = getattr(config, "gui_disable_minidashboard", False)