Skip to content

Commit

Permalink
Refactore testproject.settings to accommodate more scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaoming committed Jul 16, 2013
1 parent a4e3ebf commit 58a46b8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
12 changes: 12 additions & 0 deletions testproject/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ that you have checked out the root of the Git repository.

It comes with a prepopulated SQLite database.

Test settings
-------------

Setup
-----

Expand All @@ -14,6 +17,15 @@ You should link your wiki and django_notify folders like so
ln -s ../wiki .
ln -s ../django_notify .

Running
-------

You should be able to immediately run it like this:

python manage.py runserver --settings=testproject.settings.local

The settings come in a package to administer several test scenarios. For simple purposes, simply edit `local.py`.

Login
-----

Expand Down
2 changes: 0 additions & 2 deletions testproject/testproject/search_sites.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from os import path as os_path
PROJECT_PATH = os_path.abspath(os_path.split(__file__)[0])
PROJECT_PATH = os_path.abspath(os_path.split(os_path.dirname(__file__))[0])

DEBUG = True
TEMPLATE_DEBUG = DEBUG
Expand All @@ -9,9 +9,6 @@
# ('Your Name', '[email protected]'),
)

#from django.core.urlresolvers import reverse_lazy
#LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''})

MANAGERS = ADMINS

DATABASES = {
Expand All @@ -21,12 +18,6 @@
}
}

#Django Haystack

HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = os_path.join(PROJECT_PATH, 'index_woosh')
HAYSTACK_SITECONF = 'testproject.search_sites'

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE = 'Europe/Copenhagen'

Expand All @@ -52,23 +43,21 @@
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = 'b^fv_)t39h%9p40)fnkfblo##jkr!$0)lkp6bpy!fi*f$4*92!'

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
]

ROOT_URLCONF = 'testproject.urls'

Expand All @@ -79,7 +68,7 @@
os_path.join(PROJECT_PATH, 'templates'),
)

TEMPLATE_CONTEXT_PROCESSORS =(
TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
Expand All @@ -90,9 +79,9 @@
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'sekizai.context_processors.sekizai',
)
]

INSTALLED_APPS = (
INSTALLED_APPS = [
'django.contrib.humanize',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -114,8 +103,7 @@
'wiki.plugins.attachments',
'wiki.plugins.notifications',
'mptt',
'haystack',
)
]

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
Expand Down Expand Up @@ -150,9 +138,10 @@
WIKI_ANONYMOUS_CREATE = False

# Do not user /accounts/profile as default
LOGIN_REDIRECT_URL = "/"
#LOGIN_REDIRECT_URL = "/"
from django.core.urlresolvers import reverse_lazy
LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''})

from settings_local import *

try:
import debug_toolbar #@UnusedImport
Expand Down
16 changes: 16 additions & 0 deletions testproject/testproject/settings/customauthuser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from testproject.settings import *
from testproject.settings.local import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': os_path.join(PROJECT_PATH, 'db', 'prepopulated-customauthuser.db'), # Or path to database file if using sqlite3.
}
}

INSTALLED_APPS = INSTALLED_APPS + [
# Test application for testing custom users
'wiki.tests.testdata',
]

AUTH_USER_MODEL = 'testdata.CustomUser'
21 changes: 21 additions & 0 deletions testproject/testproject/settings/haystack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from testproject.settings import *
from testproject.settings.local import *
import os

#Django Haystack

HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_PATH, 'index_woosh')

INSTALLED_APPS += ['haystack', 'wiki.plugins.haystack']

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(PROJECT_PATH, 'whoosh_index'),
},
}

0 comments on commit 58a46b8

Please sign in to comment.