diff options
Diffstat (limited to 'postgresqleu')
-rw-r--r-- | postgresqleu/.gitignore | 1 | ||||
-rw-r--r-- | postgresqleu/__init__.py | 0 | ||||
-rwxr-xr-x | postgresqleu/manage.py | 11 | ||||
-rw-r--r-- | postgresqleu/settings.py | 78 | ||||
-rw-r--r-- | postgresqleu/static/__init__.py | 0 | ||||
-rw-r--r-- | postgresqleu/static/models.py | 3 | ||||
-rw-r--r-- | postgresqleu/static/views.py | 23 | ||||
-rw-r--r-- | postgresqleu/urls.py | 27 |
8 files changed, 143 insertions, 0 deletions
diff --git a/postgresqleu/.gitignore b/postgresqleu/.gitignore new file mode 100644 index 00000000..0d20b648 --- /dev/null +++ b/postgresqleu/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/postgresqleu/__init__.py b/postgresqleu/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/postgresqleu/__init__.py diff --git a/postgresqleu/manage.py b/postgresqleu/manage.py new file mode 100755 index 00000000..5e78ea97 --- /dev/null +++ b/postgresqleu/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/postgresqleu/settings.py b/postgresqleu/settings.py new file mode 100644 index 00000000..ecad5e1c --- /dev/null +++ b/postgresqleu/settings.py @@ -0,0 +1,78 @@ +# Django settings for postgresqleu project. + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + ('postgresql.eu webmaster', 'webmaster@postgresql.eu'), +) + +MANAGERS = ADMINS + +DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_NAME = 'postgresqleu' # Or path to database file if using sqlite3. +DATABASE_USER = 'postgresqleu' # Not used with sqlite3. +DATABASE_PASSWORD = '' # Not used with sqlite3. +DATABASE_HOST = '/tmp' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'GMT' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = False + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +#MEDIA_ROOT = '/home/mha/djangolab/postgresqleu/media' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +#MEDIA_URL = '/media/' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/admin_media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'zya5w8sfr)i(7q^p3s50-3hk5&4=k(&z6+*1x!#lt#8h%!sizu' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', +# 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', +) + +ROOT_URLCONF = 'postgresqleu.urls' + +TEMPLATE_DIRS = ( + '../template', +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'postgresqleu.static', +) diff --git a/postgresqleu/static/__init__.py b/postgresqleu/static/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/postgresqleu/static/__init__.py diff --git a/postgresqleu/static/models.py b/postgresqleu/static/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/postgresqleu/static/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/postgresqleu/static/views.py b/postgresqleu/static/views.py new file mode 100644 index 00000000..108d9424 --- /dev/null +++ b/postgresqleu/static/views.py @@ -0,0 +1,23 @@ +from django.shortcuts import render_to_response +from django.http import HttpResponse, Http404 +from django.template import TemplateDoesNotExist, loader, Context + +# Fallback handler for URLs not matching anything else. Fall them +# back to a static template. If that one is not found, send a 404 +# error. +def static_fallback(request, url): + try: + # Disallow all URLs that back-step + if url.find('..') > -1: + raise TemplateDoesNotExist + + t = loader.get_template('pages/%s.html' % url) + return HttpResponse(t.render(Context())) + + except TemplateDoesNotExist, e: + raise Http404('Page not found') + +# Handle the frontpage +def index(request): + return render_to_response('index.html') + diff --git a/postgresqleu/urls.py b/postgresqleu/urls.py new file mode 100644 index 00000000..e8f26e96 --- /dev/null +++ b/postgresqleu/urls.py @@ -0,0 +1,27 @@ +from django.conf.urls.defaults import * +from django.conf import settings +from django.contrib.auth.views import login, logout_then_login + + +import postgresqleu.static.views + +# Uncomment the next two lines to enable the admin: +# from django.contrib import admin +# admin.autodiscover() + +urlpatterns = patterns('', + # Frontpage + (r'^$', postgresqleu.static.views.index), + + # Log in/log out + (r'^login/?$', login, {'template_name':'login.html'}), + (r'^logout/?$', logout_then_login, {'login_url':'/'}), + + # This should not happen in production - serve by apache! + url(r'^media/(.*)$', 'django.views.static.serve', { + 'document_root': '../media', + }), + + # Fallback - send everything nonspecific to the static handler + (r'^(.*)$', postgresqleu.static.views.static_fallback), +) |