1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from datetime import timedelta
12 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
13 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15 # SECURITY WARNING: don't run with debug turned on in production!
16 # NOTE: os.environ only returns strings, so making a comparison to
17 # 'True' here will convert it to the correct Boolean value.
18 DEBUG = os.environ['DEBUG'] == 'True'
19 TESTING = os.environ['TEST'] == 'True'
21 # Application definition
31 'django.contrib.admin',
32 'django.contrib.auth',
33 'django.contrib.contenttypes',
34 'django.contrib.sessions',
35 'django.contrib.messages',
36 'django.contrib.staticfiles',
37 'django.contrib.humanize',
41 'rest_framework.authtoken',
45 'django.middleware.security.SecurityMiddleware',
46 'django.contrib.sessions.middleware.SessionMiddleware',
47 'django.middleware.common.CommonMiddleware',
48 'django.middleware.csrf.CsrfViewMiddleware',
49 'django.contrib.auth.middleware.AuthenticationMiddleware',
50 'django.contrib.messages.middleware.MessageMiddleware',
51 'django.middleware.clickjacking.XFrameOptionsMiddleware',
52 'account.middleware.TimezoneMiddleware',
55 ROOT_URLCONF = 'pharos_dashboard.urls'
59 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 'DIRS': [os.path.join(BASE_DIR, 'templates')]
64 'context_processors': [
65 'dashboard.context_processors.debug',
66 'django.template.context_processors.debug',
67 'django.template.context_processors.request',
68 'django.contrib.auth.context_processors.auth',
69 'django.contrib.messages.context_processors.messages',
75 TEMPLATE_CONTEXT_PROCESSORS = [
76 'dashboard.context_processors.debug',
79 WSGI_APPLICATION = 'pharos_dashboard.wsgi.application'
82 # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
84 AUTH_PASSWORD_VALIDATORS = [
86 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
89 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
92 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
95 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
99 # Internationalization
100 # https://docs.djangoproject.com/en/1.10/topics/i18n/
102 LANGUAGE_CODE = 'en-us'
112 # Static files (CSS, JavaScript, Images)
113 # https://docs.djangoproject.com/en/1.10/howto/static-files/
114 MEDIA_URL = '/media/'
115 STATIC_URL = '/static/'
117 # Static files (CSS, JavaScript, Images)
118 # https://docs.djangoproject.com/en/1.10/howto/static-files/
120 os.path.join(BASE_DIR, "static"),
123 LOGIN_REDIRECT_URL = '/'
125 # SECURITY WARNING: keep the secret key used in production secret!
126 SECRET_KEY = os.environ['SECRET_KEY']
129 'set_placeholder': False,
132 ALLOWED_HOSTS = ['*']
135 # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
138 'ENGINE': 'django.db.backends.postgresql',
139 'NAME': os.environ['DB_NAME'],
140 'USER': os.environ['DB_USER'],
141 'PASSWORD': os.environ['DB_PASS'],
142 'HOST': os.environ['DB_SERVICE'],
143 'PORT': os.environ['DB_PORT']
149 'DEFAULT_PERMISSION_CLASSES': [
150 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
152 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.FilterSet',),
153 'DEFAULT_AUTHENTICATION_CLASSES': (
154 'rest_framework.authentication.SessionAuthentication',
155 'rest_framework.authentication.TokenAuthentication',
159 MEDIA_ROOT = '/media'
160 STATIC_ROOT = '/static'
163 CREATE_JIRA_TICKET = False
165 JIRA_URL = os.environ['JIRA_URL']
167 JIRA_USER_NAME = os.environ['JIRA_USER_NAME']
168 JIRA_USER_PASSWORD = os.environ['JIRA_USER_PASSWORD']
170 OAUTH_CONSUMER_KEY = os.environ['OAUTH_CONSUMER_KEY']
171 OAUTH_CONSUMER_SECRET = os.environ['OAUTH_CONSUMER_SECRET']
173 OAUTH_REQUEST_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/request-token'
174 OAUTH_ACCESS_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/access-token'
175 OAUTH_AUTHORIZE_URL = JIRA_URL + '/plugins/servlet/oauth/authorize'
177 OAUTH_CALLBACK_URL = os.environ['DASHBOARD_URL'] + '/accounts/authenticated'
180 CELERY_TIMEZONE = 'UTC'
182 RABBITMQ_URL = 'rabbitmq'
183 RABBITMQ_DEFAULT_USER = os.environ['RABBITMQ_DEFAULT_USER']
184 RABBITMQ_DEFAULT_PASS = os.environ['RABBITMQ_DEFAULT_PASS']
186 BROKER_URL = 'amqp://' + RABBITMQ_DEFAULT_USER + ':' + RABBITMQ_DEFAULT_PASS + '@rabbitmq:5672//'
188 CELERYBEAT_SCHEDULE = {
190 'task': 'dashboard.tasks.booking_poll',
191 'schedule': timedelta(minutes=1)
194 'task': 'dashboard.tasks.free_hosts',
195 'schedule': timedelta(minutes=1)
197 'conjure_notifiers': {
198 'task': 'dashboard.tasks.conjure_aggregate_notifiers',
199 'schedule': timedelta(seconds=30)
204 EMAIL_HOST = os.environ['EMAIL_HOST']
205 EMAIL_PORT = os.environ['EMAIL_PORT']
206 EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER']
207 EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD']
209 DEFAULT_EMAIL_FROM = os.environ.get('DEFAULT_EMAIL_FROM', 'webmaster@localhost')
210 SESSION_ENGINE="django.contrib.sessions.backends.signed_cookies"