aboutsummaryrefslogtreecommitdiffstats
path: root/src/pharos_dashboard
diff options
context:
space:
mode:
authorTrevor Bramwell <tbramwell@linuxfoundation.org>2017-09-22 12:23:36 -0700
committerTrevor Bramwell <tbramwell@linuxfoundation.org>2017-09-22 12:23:36 -0700
commitb07bbdba03fe9b1c3da2f69b8bc28b8071d99ec1 (patch)
treeed2a67f71eb8f3d3e8e3c284e7d53f91ecd6cd96 /src/pharos_dashboard
Rename pharos-dashboard and pharos-validator
As subdirectories of the pharos-tools repo, there is little need to keep the pharos prefix. Change-Id: Ica3d79411f409df638647300036c0664183c2725 Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'src/pharos_dashboard')
-rw-r--r--src/pharos_dashboard/__init__.py13
-rw-r--r--src/pharos_dashboard/celery.py30
-rw-r--r--src/pharos_dashboard/settings.py184
-rw-r--r--src/pharos_dashboard/urls.py44
-rw-r--r--src/pharos_dashboard/wsgi.py26
5 files changed, 297 insertions, 0 deletions
diff --git a/src/pharos_dashboard/__init__.py b/src/pharos_dashboard/__init__.py
new file mode 100644
index 0000000..f104c4d
--- /dev/null
+++ b/src/pharos_dashboard/__init__.py
@@ -0,0 +1,13 @@
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+# This will make sure the app is always imported when
+# Django starts so that shared_task will use this app.
+from .celery import app as celery_app # noqa
diff --git a/src/pharos_dashboard/celery.py b/src/pharos_dashboard/celery.py
new file mode 100644
index 0000000..f60f243
--- /dev/null
+++ b/src/pharos_dashboard/celery.py
@@ -0,0 +1,30 @@
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+import os
+
+from celery import Celery
+
+# set the default Django settings module for the 'celery' program.
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pharos_dashboard.settings')
+
+from django.conf import settings # noqa
+
+app = Celery('pharos_dashboard')
+
+# Using a string here means the worker will not have to
+# pickle the object when using Windows.
+app.config_from_object('django.conf:settings')
+app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
+
+
+@app.task(bind=True)
+def debug_task(self):
+ print('Request: {0!r}'.format(self.request)) \ No newline at end of file
diff --git a/src/pharos_dashboard/settings.py b/src/pharos_dashboard/settings.py
new file mode 100644
index 0000000..546b174
--- /dev/null
+++ b/src/pharos_dashboard/settings.py
@@ -0,0 +1,184 @@
+import os
+from datetime import timedelta
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'dashboard',
+ 'booking',
+ 'account',
+ 'jenkins',
+ 'notification',
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'django.contrib.humanize',
+ 'bootstrap3',
+ 'crispy_forms',
+ 'rest_framework',
+ 'rest_framework.authtoken',
+]
+
+MIDDLEWARE = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'account.middleware.TimezoneMiddleware',
+]
+
+ROOT_URLCONF = 'pharos_dashboard.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [os.path.join(BASE_DIR, 'templates')]
+ ,
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
+
+WSGI_APPLICATION = 'pharos_dashboard.wsgi.application'
+
+# Password validation
+# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+ {
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+ },
+]
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.10/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.10/howto/static-files/
+MEDIA_URL = '/media/'
+STATIC_URL = '/static/'
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.10/howto/static-files/
+STATICFILES_DIRS = [
+ os.path.join(BASE_DIR, "static"),
+]
+
+LOGIN_REDIRECT_URL = '/'
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = os.environ['SECRET_KEY']
+
+BOOTSTRAP3 = {
+ 'set_placeholder': False,
+}
+
+ALLOWED_HOSTS = ['*']
+
+# Database
+# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'NAME': os.environ['DB_NAME'],
+ 'USER': os.environ['DB_USER'],
+ 'PASSWORD': os.environ['DB_PASS'],
+ 'HOST': os.environ['DB_SERVICE'],
+ 'PORT': os.environ['DB_PORT']
+ }
+}
+
+
+# Rest API Settings
+REST_FRAMEWORK = {
+ 'DEFAULT_PERMISSION_CLASSES': [
+ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
+ ],
+ 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',),
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
+ 'rest_framework.authentication.SessionAuthentication',
+ 'rest_framework.authentication.TokenAuthentication',
+ )
+}
+
+MEDIA_ROOT = '/media'
+STATIC_ROOT = '/static'
+
+# Jira Settings
+CREATE_JIRA_TICKET = False
+
+JIRA_URL = os.environ['JIRA_URL']
+
+JIRA_USER_NAME = os.environ['JIRA_USER_NAME']
+JIRA_USER_PASSWORD = os.environ['JIRA_USER_PASSWORD']
+
+OAUTH_CONSUMER_KEY = os.environ['OAUTH_CONSUMER_KEY']
+OAUTH_CONSUMER_SECRET = os.environ['OAUTH_CONSUMER_SECRET']
+
+OAUTH_REQUEST_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/request-token'
+OAUTH_ACCESS_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/access-token'
+OAUTH_AUTHORIZE_URL = JIRA_URL + '/plugins/servlet/oauth/authorize'
+
+OAUTH_CALLBACK_URL = os.environ['DASHBOARD_URL'] + '/accounts/authenticated'
+
+# Celery Settings
+CELERY_TIMEZONE = 'UTC'
+
+RABBITMQ_URL = 'rabbitmq'
+RABBITMQ_USER = os.environ['RABBITMQ_USER']
+RABBITMQ_PASSWORD = os.environ['RABBITMQ_PASSWORD']
+
+BROKER_URL = 'amqp://' + RABBITMQ_USER + ':' + RABBITMQ_PASSWORD + '@rabbitmq:5672//'
+
+CELERYBEAT_SCHEDULE = {
+ 'sync-jenkins': {
+ 'task': 'jenkins.tasks.sync_jenkins',
+ 'schedule': timedelta(minutes=5)
+ },
+ 'send-booking-notifications': {
+ 'task': 'notification.tasks.send_booking_notifications',
+ 'schedule': timedelta(minutes=5)
+ },
+ 'clean-database': {
+ 'task': 'dashboard.tasks.database_cleanup',
+ 'schedule': timedelta(hours=24)
+ },
+}
diff --git a/src/pharos_dashboard/urls.py b/src/pharos_dashboard/urls.py
new file mode 100644
index 0000000..adcb5b8
--- /dev/null
+++ b/src/pharos_dashboard/urls.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+"""pharos_dashboard URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/1.10/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.conf.urls import url, include
+ 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
+"""
+from django.conf import settings
+from django.conf.urls import url, include
+from django.conf.urls.static import static
+from django.contrib import admin
+
+
+urlpatterns = [
+ url(r'^', include('dashboard.urls', namespace='dashboard')),
+ url(r'^booking/', include('booking.urls', namespace='booking')),
+ url(r'^accounts/', include('account.urls', namespace='account')),
+
+ url(r'^admin/', admin.site.urls),
+ url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
+
+ url(r'^api/', include('api.urls'))
+]
+
+if settings.DEBUG is True:
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file
diff --git a/src/pharos_dashboard/wsgi.py b/src/pharos_dashboard/wsgi.py
new file mode 100644
index 0000000..3d43361
--- /dev/null
+++ b/src/pharos_dashboard/wsgi.py
@@ -0,0 +1,26 @@
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+"""
+WSGI config for pharos_dashboard project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pharos_dashboard.settings")
+
+application = get_wsgi_application()