summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Page2016-03-14 11:29:18 +0000
committerDave Page2016-03-14 11:29:18 +0000
commit415c5f55df04fc4a56aa4297532ae177249a9d89 (patch)
tree04db6e6df0bd076b13463a0999abda7d906adde5
Initial import of a framework Django app.
-rw-r--r--.gitignore5
-rw-r--r--README.rst47
-rw-r--r--requirements.txt2
-rwxr-xr-xweb/manage.py10
-rw-r--r--web/web/__init__.py0
-rw-r--r--web/web/settings.py105
-rw-r--r--web/web/settings_local.py.in12
-rw-r--r--web/web/urls.py20
-rw-r--r--web/web/wsgi.py16
9 files changed, 217 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..21620ab
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+web/web/settings_local.py
+migrations
+*.pyc
+*.swp
+*.psp
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..189fcd2
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,47 @@
+PostgreSQL Performance Farm
+===========================
+
+This repository contains the code for the PostgreSQL Performance Farm.
+
+web/
+----
+
+The web/ directory contains the Django application that forms the basis of the
+website. In order to run the site, you will need to setup a Python virtualenv,
+e.g::
+
+ $ sudo pip install virtualenvwrapper
+ $ source /usr/local/bin/virtualenvwrapper.sh
+ $ mkvirtualenv pgperffarm
+
+For ease of future use, configure virtualenvs from your .bash_profile::
+
+ $ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bash_profile
+
+To activate the environment in future sessions, run::
+
+ $ workon helpdesk
+
+Then, install the required modules. Note that we use Django 1.8.11 as that's
+what is currently supported on the postgresql.org infrastructure::
+
+ $ PATH=$PATH:/usr/local/pgsql/bin pip install -r requirements.txt
+
+Next, create a settings_local.py file::
+
+ $ cp web/web/settings_local.py.in web/web/settings_local.py
+
+Edit the file and change the database configuration and other settings to suit
+your environment. Make sure you create the required database and user account
+on your PostgreSQL server.
+
+Finally, synchronise the database::
+
+ $ python manage.py syncdb
+
+That should be all. To test, run the following command and point a browser at
+the URL shown::
+
+ $ python manage.py runserver
+
+You should see the index page of the application.
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..b7a5b19
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+Django==1.8.11
+psycopg2==2.6.1
diff --git a/web/manage.py b/web/manage.py
new file mode 100755
index 0000000..40507fb
--- /dev/null
+++ b/web/manage.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
diff --git a/web/web/__init__.py b/web/web/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/web/web/__init__.py
diff --git a/web/web/settings.py b/web/web/settings.py
new file mode 100644
index 0000000..ed08172
--- /dev/null
+++ b/web/web/settings.py
@@ -0,0 +1,105 @@
+"""
+Django settings for web project.
+
+Generated by 'django-admin startproject' using Django 1.8.11.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.8/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/1.8/ref/settings/
+"""
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+import os
+
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '35lixc=ebz)1q)u2e7_jj*2#34$t3=7m^&5&-1-2#6=f=nw4-+'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'django.middleware.security.SecurityMiddleware',
+)
+
+ROOT_URLCONF = 'web.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [],
+ '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 = 'web.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ }
+}
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.8/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.8/howto/static-files/
+
+STATIC_URL = '/static/'
+
+# Load local settings overrides
+from settings_local import *
diff --git a/web/web/settings_local.py.in b/web/web/settings_local.py.in
new file mode 100644
index 0000000..fbe4ac6
--- /dev/null
+++ b/web/web/settings_local.py.in
@@ -0,0 +1,12 @@
+DEBUG=True
+
+DATABASES={
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'pgperffarm',
+ 'USER': 'pgperffarm',
+ 'PASSWORD': 'pgperffarm',
+ 'HOST': '/tmp'
+ }
+ }
+
diff --git a/web/web/urls.py b/web/web/urls.py
new file mode 100644
index 0000000..cea6793
--- /dev/null
+++ b/web/web/urls.py
@@ -0,0 +1,20 @@
+"""web URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/1.8/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. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
+"""
+from django.conf.urls import include, url
+from django.contrib import admin
+
+urlpatterns = [
+ url(r'^admin/', include(admin.site.urls)),
+]
diff --git a/web/web/wsgi.py b/web/web/wsgi.py
new file mode 100644
index 0000000..c291b5c
--- /dev/null
+++ b/web/web/wsgi.py
@@ -0,0 +1,16 @@
+"""
+WSGI config for web 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.8/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings")
+
+application = get_wsgi_application()