-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #543 from benjaoming/testproject-layout
Modernize testproject layout
- Loading branch information
Showing
9 changed files
with
199 additions
and
183 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+365 KB
testproject/prepopulated.db → testproject/testproject/db/prepopulated.db
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,175 +1,7 @@ | ||
from __future__ import absolute_import | ||
from __future__ import unicode_literals | ||
# -*- coding: utf-8 -*- | ||
from os import path as os_path | ||
PROJECT_PATH = os_path.abspath(os_path.split(os_path.dirname(__file__))[0]) | ||
from __future__ import unicode_literals, absolute_import | ||
|
||
DEBUG = True | ||
|
||
ADMINS = ( | ||
# ('Your Name', 'your_email@example.com'), | ||
) | ||
|
||
MANAGERS = ADMINS | ||
|
||
DATABASES = { | ||
'default': { | ||
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
# Or path to database file if using sqlite3. | ||
'NAME': 'prepopulated.db', | ||
} | ||
} | ||
|
||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
TIME_ZONE = 'Europe/Copenhagen' | ||
|
||
# http://www.i18nguy.com/unicode/language-identifiers.html | ||
LANGUAGE_CODE = 'en-dk' | ||
|
||
SITE_ID = 1 | ||
|
||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
MEDIA_ROOT = os_path.join(PROJECT_PATH, 'media') | ||
MEDIA_URL = '/media/' | ||
|
||
STATIC_ROOT = os_path.join(PROJECT_PATH, 'static') | ||
STATIC_URL = '/static/' | ||
STATICFILES_DIRS = ( | ||
) | ||
STATICFILES_FINDERS = ( | ||
'django.contrib.staticfiles.finders.FileSystemFinder', | ||
'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
) | ||
|
||
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' | ||
|
||
# Python dotted path to the WSGI application used by Django's runserver. | ||
WSGI_APPLICATION = 'testproject.wsgi.application' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'APP_DIRS': True, | ||
'DIRS': (os_path.join(PROJECT_PATH, 'templates'),), | ||
'OPTIONS': { | ||
'context_processors': [ | ||
"django.contrib.auth.context_processors.auth", | ||
"django.template.context_processors.debug", | ||
"django.template.context_processors.i18n", | ||
"django.template.context_processors.media", | ||
"django.template.context_processors.request", | ||
"django.template.context_processors.static", | ||
"django.template.context_processors.tz", | ||
"django.contrib.messages.context_processors.messages", | ||
"sekizai.context_processors.sekizai", | ||
], | ||
'debug': DEBUG, | ||
} | ||
}, | ||
] | ||
|
||
# Setting this dynamically: | ||
# for template_engine in TEMPLATES: | ||
# template_engine['OPTIONS']['debug'] = True | ||
|
||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.humanize', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.sites', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'django.contrib.admin', | ||
'django.contrib.admindocs', | ||
'sekizai', | ||
'sorl.thumbnail', | ||
'django_nyt', | ||
'wiki', | ||
'wiki.plugins.macros', | ||
'wiki.plugins.help', | ||
'wiki.plugins.links', | ||
'wiki.plugins.images', | ||
'wiki.plugins.attachments', | ||
'wiki.plugins.notifications', | ||
'mptt', | ||
] | ||
from django import VERSION | ||
if VERSION < (1, 7): | ||
INSTALLED_APPS.append('south') | ||
else: | ||
TEST_RUNNER = 'django.test.runner.DiscoverRunner' | ||
|
||
# A sample logging configuration. The only tangible logging | ||
# performed by this configuration is to send an email to | ||
# the site admins on every HTTP 500 error when DEBUG=False. | ||
# See http://docs.djangoproject.com/en/dev/topics/logging for | ||
# more details on how to customize your logging configuration. | ||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
'filters': { | ||
'require_debug_false': { | ||
'()': 'django.utils.log.RequireDebugFalse' | ||
} | ||
}, | ||
'handlers': { | ||
'mail_admins': { | ||
'level': 'ERROR', | ||
'filters': ['require_debug_false'], | ||
'class': 'django.utils.log.AdminEmailHandler' | ||
} | ||
}, | ||
'loggers': { | ||
'django.request': { | ||
'handlers': ['mail_admins'], | ||
'level': 'ERROR', | ||
'propagate': True, | ||
}, | ||
} | ||
} | ||
|
||
WIKI_ANONYMOUS_WRITE = True | ||
WIKI_ANONYMOUS_CREATE = False | ||
|
||
# Do not user /accounts/profile as default | ||
#LOGIN_REDIRECT_URL = "/" | ||
from django.core.urlresolvers import reverse_lazy | ||
LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''}) | ||
|
||
|
||
try: | ||
import debug_toolbar # @UnusedImport | ||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES) + [ | ||
'debug_toolbar.middleware.DebugToolbarMiddleware', | ||
] | ||
INSTALLED_APPS = list(INSTALLED_APPS) + ['debug_toolbar'] | ||
INTERNAL_IPS = ('127.0.0.1',) | ||
DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} | ||
except ImportError: | ||
pass | ||
|
||
|
||
# "Secret" key for the prepopulated db | ||
SECRET_KEY = 'b^fv_)t39h%9p40)fnkfblo##jkr!$0)lkp6bpy!fi*f$4*92!' | ||
|
||
try: | ||
from testproject.settings.local import * | ||
from .local import * | ||
except ImportError: | ||
pass | ||
from .base import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Generated by 'django-admin startproject' using Django 1.9.5. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.9/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/1.9/ref/settings/ | ||
""" | ||
|
||
from __future__ import unicode_literals | ||
|
||
import os | ||
|
||
from django import VERSION | ||
from django.core.urlresolvers import reverse_lazy | ||
|
||
|
||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
BASE_DIR = os.path.dirname(PROJECT_DIR) | ||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'b^fv_)t39h%9p40)fnkfblo##jkr!$0)lkp6bpy!fi*f$4*92!' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = False | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
|
||
# Application definition | ||
|
||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.humanize', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.sites', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'django.contrib.admin', | ||
'django.contrib.admindocs', | ||
'sekizai', | ||
'sorl.thumbnail', | ||
'django_nyt', | ||
'wiki', | ||
'wiki.plugins.macros', | ||
'wiki.plugins.help', | ||
'wiki.plugins.links', | ||
'wiki.plugins.images', | ||
'wiki.plugins.attachments', | ||
'wiki.plugins.notifications', | ||
'mptt', | ||
] | ||
if VERSION < (1, 7): | ||
INSTALLED_APPS.append('south') | ||
else: | ||
TEST_RUNNER = 'django.test.runner.DiscoverRunner' | ||
|
||
|
||
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 = 'testproject.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [ | ||
os.path.join(PROJECT_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', | ||
], | ||
'debug': DEBUG, | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'testproject.wsgi.application' | ||
|
||
|
||
LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''}) | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(PROJECT_DIR, 'db', 'prepopulated.db'), | ||
} | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/1.9/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.9/topics/i18n/ | ||
|
||
TIME_ZONE = 'Europe/Berlin' | ||
|
||
# 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 | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/1.9/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') | ||
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') | ||
MEDIA_URL = '/media/' | ||
|
||
|
||
WIKI_ANONYMOUS_WRITE = True | ||
WIKI_ANONYMOUS_CREATE = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from .base import * # noqa @UnusedWildImport | ||
|
||
DEBUG = True | ||
|
||
|
||
for template_engine in TEMPLATES: | ||
template_engine['OPTIONS']['debug'] = True | ||
|
||
|
||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||
|
||
|
||
try: | ||
import debug_toolbar # @UnusedImport | ||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES) + [ | ||
'debug_toolbar.middleware.DebugToolbarMiddleware', | ||
] | ||
INSTALLED_APPS = list(INSTALLED_APPS) + ['debug_toolbar'] | ||
INTERNAL_IPS = ('127.0.0.1',) | ||
DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} | ||
except ImportError: | ||
pass |
Oops, something went wrong.