Commit 4c831909 by Stephen Sanchez

Merge pull request #1 from edx/sanchez/add_repo_config_files

Adding a number of repo config files.
parents c17c1734 c3f31e38
# .coveragerc for edx-ecommerce
[run]
data_file = .coverage
source = edx/edx-ecommerce
[report]
ignore_errors = True
[html]
title = EdX E-Commerce Front End Python Test Coverage Report
directory = report
[xml]
output = coverage.xml
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
__pycache__
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
unittests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# QA
coverage.xml
diff_*.html
*.report
report
edx_ecommerce.log
venv
# Override config files
override.cfg
# JetBrains
.idea
.DS_Store
*.trace
[pep8]
ignore=E501
max_line_length=119
.PHONY: requirements
ROOT = $(shell echo "$$PWD")
COVERAGE = $(ROOT)/build/coverage
PACKAGES = verification_workflow
NUM_PROCESSES = 2
NODE_BIN=./node_modules/.bin
DJANGO_SETTINGS_MODULE := "settings.local"
.PHONY: requirements clean
requirements: requirements.js
pip install -q -r requirements/base.txt --exists-action w
requirements.js:
npm install
$(NODE_BIN)/bower install
test.requirements: requirements
pip install -q -r requirements/test.txt --exists-action w
develop: test.requirements
pip install -q -r requirements/local.txt --exists-action w
test.acceptance: develop
git clone https://github.com/edx/edx-ecommerce.git
pip install -q -r edx-ecommerce/requirements/base.txt
migrate:
./manage.py migrate
clean:
find . -name '*.pyc' -delete
coverage erase
test_python: clean
./manage.py test --settings=settings.test --with-ignore-docstrings \
--exclude-dir=settings --exclude-dir=migrations --with-coverage \
--cover-inclusive --cover-branches --cover-html --cover-html-dir=$(COVERAGE)/html/ \
--cover-xml --cover-xml-file=$(COVERAGE)/coverage.xml \
$(foreach package,$(PACKAGES),--cover-package=$(package)) \
$(PACKAGES)
accept:
nosetests -v $PACKAGES --processes=$(NUM_PROCESSES) --process-timeout=120 --exclude-dir=acceptance_tests/course_validation
quality:
pep8 --config=.pep8 $PACKAGES
pylint --rcfile=../pylintrc $(PACKAGES)
validate_python: test.requirements test_python quality
validate_js: requirements.js
$(NODE_BIN)/gulp test
$(NODE_BIN)/gulp lint
$(NODE_BIN)/gulp jscs
validate: validate_python validate_js
compile_translations:
i18n_tool generate -v
extract_translations:
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} PYTHONPATH=".:$PYTHONPATH" i18n_tool extract -v
dummy_translations:
i18n_tool dummy -v
generate_fake_translations: extract_translations dummy_translations compile_translations
pull_translations:
tx pull -a
update_translations: pull_translations generate_fake_translations
static:
$(NODE_BIN)/r.js -o build.js
./manage.py collectstatic --noinput
./manage.py compress
#!/usr/bin/env bash
# TODO: Determine how we want to collect all static assets.
BOWER_COMPONENTS_PATH="static/bower_components"
function CSS2SCSS() {
filename=$1
css_filename=${filename}.css
if [ -f ${css_filename} ]; then
mv ${css_filename} ${filename}.scss
fi
}
# "Convert" the CSS to SCSS since SASS can only import .scss files.
CSS2SCSS ${BOWER_COMPONENTS_PATH}/bootstrapaccessibilityplugin/plugins/css/bootstrap-accessibility
CSS2SCSS ${BOWER_COMPONENTS_PATH}/nvd3/nv.d3
# Download the CLDR data for all locales
CLDR_DATA_PATH=${BOWER_COMPONENTS_PATH}/cldr-data
node ./node_modules/cldr-data-downloader/bin/download.js -i ${CLDR_DATA_PATH}/index.json -o ${CLDR_DATA_PATH}
{
"name": "edx-ecommerce",
"homepage": "https://github.com/edx/edx-ecommerce",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"globalize": "1.0.0-alpha.14",
"requirejs-plugins": "~1.0.2",
"bootstrap-sass-official": "v3.2.0+2",
"jquery": "~1.11.1",
"bootstrapaccessibilityplugin": "~1.0.3",
"underscore": "~1.7.0",
"backbone": "~1.1.2",
"d3": "~3.3.13",
"requirejs": "~2.1.15",
"nvd3": "~1.1.15-beta",
"jasmine": "~2.0.4",
"moment": "~2.8.3",
"topojson": "~1.4.3",
"datamaps": "~0.3.4",
"datatables": "~1.10.2",
"font-awesome": "~4.2.0",
"natural-sort": "overset/javascript-natural-sort#dbf4ca259b327a488bd1d7897fd46d80c414a7e0"
},
"resolutions": {
"cldrjs": "0.3.10"
}
}
/* jshint asi: true, expr:true */
({
mainConfigFile: 'static/js/config.js',
baseUrl: 'static',
dir: 'static/dist',
removeCombined: true,
findNestedDependencies: true,
// Disable all optimization. django-compressor will handle that for us.
optimizeCss: false,
optimize: 'none',
normalizeDirDefines: 'all',
skipDirOptimize: true,
preserveLicenseComments: true,
modules: [
{
name: 'js/common'
},
{
name: 'js/config'
},
{
name: 'js/engagement-content-main',
exclude: ['js/common']
},
{
name: 'js/enrollment-activity-main',
exclude: ['js/common']
},
{
name: 'js/enrollment-geography-main',
exclude: ['js/common']
},
{
name: 'js/enrollment-demographics-age-main',
exclude: ['js/common']
},
{
name: 'js/enrollment-demographics-education-main',
exclude: ['js/common']
},
{
name: 'js/enrollment-demographics-gender-main',
exclude: ['js/common']
},
{
name: 'js/performance-answer-distribution-main',
exclude: ['js/common']
}
]
})
(function () {
'use strict';
var jshint = require('gulp-jshint'),
gulp = require('gulp'),
karma = require('karma').server,
path = require('path'),
browserSync = require('browser-sync'),
jscs = require('gulp-jscs'),
paths = {
spec: [
'static/js/**/*.js',
'static/js/test/**/*.js'
],
lint: [
'build.js',
'gulpfile.js',
'static/js/**/*.js',
'static/js/test/**/*.js'
],
templates: [
'templates/*.html'
],
sass: ['static/sass/*.scss'],
karamaConf: 'karma.conf.js'
};
// kicks up karma to the tests once
function runKarma(configFile, cb) {
karma.start({
configFile: path.resolve(configFile),
singleRun: true
}, cb);
}
gulp.task('lint', function () {
return gulp.src(paths.lint)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', function () {
return gulp.src(paths.lint)
.pipe(jscs());
});
// this task runs the tests. It doesn't give you very detailed results,
// so you may need to run the jasmine test page directly:
// http://127.0.0.1:8000/static/js/test/spec-runner.html
gulp.task('test', function (cb) {
runKarma(paths.karamaConf, cb);
});
// these are the default tasks when you run gulp
gulp.task('default', ['test', 'lint']);
// type 'gulp watch' to continuously run linting and tests
gulp.task('watch', function () {
gulp.watch(paths.spec, ['test', 'lint']);
});
// Proxy to django server (assuming that we're using port 8000 and
// localhost)
gulp.task('browser-sync', function () {
// there is a little delay before reloading b/c the sass files need to
// recompile, but we can't necessarily watch the generated directory
// because django creates a new css file that browser-sync doesn't
// know of and I can't figure out how to make it watch an entire
// directory
browserSync.init(null, {
proxy: 'localhost:9000',
files: paths.lint.concat(paths.templates).concat(paths.sass),
reloadDelay: 1000
});
});
}());
// Karma configuration
// Generated on Thu Jun 26 2014 17:49:39 GMT-0400 (EDT)
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs', 'sinon'],
// list of files / patterns to load in the browser
files: [
{pattern: 'static/vendor/**/*.js', included: false},
{pattern: 'static/bower_components/**/*.js', included: false},
{pattern: 'static/bower_components/**/*.json', included: false},
{pattern: 'static/js/models/**/*.js', included: false},
{pattern: 'static/js/views/**/*.js', included: false},
{pattern: 'static/js/utils/**/*.js', included: false},
{pattern: 'static/js/test/specs/*.js', included: false},
'static/js/config.js',
'static/js/test/spec-runner.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'static/js/models/**/*.js': ['coverage'],
'static/js/views/**/*.js': ['coverage'],
'static/js/utils/**/*.js': ['coverage']
},
// plugins required for running the karma tests
plugins:[
'karma-jasmine',
'karma-requirejs',
'karma-phantomjs-launcher',
'karma-coverage',
'karma-sinon'
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
coverageReporter: {
dir:'build', subdir: 'coverage-js',
reporters:[
{type: 'html', subdir: 'coverage-js/html'},
{type: 'cobertura', file: 'coverage.xml'},
{type: 'text-summary'}
]
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
// you can also add Chrome or other browsers too
browsers: ['PhantomJS'],
captureTimeout: 60000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.local")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=''
# Profiled execution.
profile=no
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS, migrations, settings, wsgi.py
# Pickle collected data for later comparisons.
persistent=yes
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
[MESSAGES CONTROL]
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
disable=
# Never going to use these
# I0011: Locally disabling W0232
# W0141: Used builtin function 'map'
# W0142: Used * or ** magic
# R0921: Abstract class not referenced
# R0922: Abstract class is only referenced 1 times
I0011,W0141,W0142,R0921,R0922,
# Django makes classes that trigger these
# W0232: Class has no __init__ method
W0232,
# Might use these when the code is in better shape
# C0302: Too many lines in module
# R0201: Method could be a function
# R0901: Too many ancestors
# R0902: Too many instance attributes
# R0903: Too few public methods (1/2)
# R0904: Too many public methods
# R0911: Too many return statements
# R0912: Too many branches
# R0913: Too many arguments
# R0914: Too many local variables
C0302,R0201,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,
# W0511: TODOs etc
W0511,
# E1103: maybe no member
E1103,
# C0111: missing docstring (handled by pep257)
C0111,
duplicate-code,
# We can decide if names are invalid on our own
invalid-name,
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html
output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no
# Tells whether to display a full report or only the messages
reports=no
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Add a comment according to your evaluation note. This is used by the global
# evaluation report (RP0004).
comment=no
[TYPECHECK]
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject
# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
zope=no
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
generated-members=
REQUEST,
acl_users,
aq_parent,
objects,
DoesNotExist,
can_read,
can_write,
get_url,
size,
content,
status_code,
# For factory_boy factories
create
[BASIC]
# Required attributes for module, separated by a comma
required-attributes=
# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input
# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression which should only match correct module level names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns)$
# Regular expression which should only match correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$
# Regular expression which should only match correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct method names
method-rgx=([a-z_][a-z0-9_]{2,60}|setUp|set[Uu]pClass|tearDown|tear[Dd]ownClass|assert[A-Z]\w*)$
# Regular expression which should only match correct instance attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct variable names
variable-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct list comprehension /
# generator expression variable names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,ex,Run,_
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Regular expression which should only match functions or classes name which do
# not require a docstring
no-docstring-rgx=__.*__|test_.*|setUp|tearDown
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=120
# Maximum number of lines in a module
max-module-lines=1000
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=4
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
[VARIABLES]
# Tells whether we should check for unused import in __init__ files.
init-import=no
# A regular expression matching the beginning of the name of dummy variables
# (i.e. not used).
dummy-variables-rgx=_|dummy|unused|.*_unused
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
[IMPORTS]
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of branch for function / method body
max-branchs=12
# Maximum number of statements in function / method body
max-statements=50
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
[CLASSES]
# List of interface methods to ignore, separated by a comma. This is used for
# instance to not check methods defines in Zope's Interface base class.
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
# This file is here because many Platforms as a Service look for
# requirements.txt in the root directory of a project.
-r requirements/production.txt
# Base Requirements for the E-Commerce Service.
Django==1.7.1 # BSD License
django-appconf==0.6
django_compressor==1.4 # MIT
django-libsass==0.2 # BSD
django-model-utils==1.5.0 # BSD
django-waffle==0.10 # BSD
logutils==0.3.3 # BSD
# Dependencies for building documentation
-r base.txt
Sphinx==1.2.1
sphinx_rtd_theme==0.1.6
\ No newline at end of file
# Local development dependencies go here
-r base.txt
django-debug-toolbar==1.2.2
transifex-client==0.10
# Pro-tip: Try not to put anything here. There should be no dependency in
# production that isn't in development.
-r base.txt
# TODO: Determine production requirements, keep this file as a template - Steve
#MySQL-python==1.2.5 # GPL License
#PyYAML==3.11 # MIT License
#gunicorn==0.17.4 # MIT
#path.py==5.2 # MIT
#python-memcached==1.53
#nodeenv==0.11.1
# Test dependencies go here.
-r base.txt
coverage==3.7.1
pep8==1.5.7
pylint==1.2.1
pep257==0.3.2
bok-choy>=0.3.1
nose-exclude==0.2.0
django-nose==1.2
nose==1.3.3
mock==1.0.1
#django-dynamic-fixture==1.7.0
-e git+https://github.com/paulocheque/django-dynamic-fixture.git@010913bfab1b010458570ec282abe80b8fd20ade#egg=django-dynamic-fixture
sure==1.2.7
httpretty==0.8.3
testfixtures==4.0.1
nose-ignore-docstring==0.2
pyquery>=1.2.9
selenium>=2.43.0
ddt==0.8.0
"""Common settings and globals."""
import ConfigParser
import os
from os.path import abspath, basename, dirname, join, normpath
from sys import path
########## PATH CONFIGURATION
# Absolute filesystem path to the Django project directory:
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
# Absolute filesystem path to the top-level project folder:
SITE_ROOT = dirname(DJANGO_ROOT)
# Site name:
SITE_NAME = basename(DJANGO_ROOT)
# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(DJANGO_ROOT)
########## END PATH CONFIGURATION
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
########## MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = (
('Your Name', 'your_email@example.com'),
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS
########## END MANAGER CONFIGURATION
########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.',
'NAME': '',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
########## END DATABASE CONFIGURATION
########## GENERAL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
TIME_ZONE = 'America/New_York'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = 'en-us'
LOCALE_PATHS = (
join(SITE_ROOT, 'conf', 'locale'),
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
FORMAT_MODULE_PATH = 'formats'
########## END GENERAL CONFIGURATION
########## MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = normpath(join(SITE_ROOT, 'media'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = '/media/'
########## END MEDIA CONFIGURATION
########## STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
normpath(join(SITE_ROOT, 'static')),
)
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),
)
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter']
########## END STATIC FILE CONFIGURATION
########## SITE CONFIGURATION
# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []
########## END SITE CONFIGURATION
########## FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
FIXTURE_DIRS = (
normpath(join(SITE_ROOT, 'fixtures')),
)
########## END FIXTURE CONFIGURATION
########## TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
TEMPLATE_DIRS = (
normpath(join(SITE_ROOT, 'templates')),
)
ALLOWED_INCLUDE_ROOTS = (
normpath(join(SITE_ROOT, 'templates')),
)
########## END TEMPLATE CONFIGURATION
########## MIDDLEWARE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'waffle.middleware.WaffleMiddleware',
)
########## END MIDDLEWARE CONFIGURATION
########## URL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
ROOT_URLCONF = '%s.urls' % SITE_NAME
########## END URL CONFIGURATION
########## APP CONFIGURATION
DJANGO_APPS = (
# Default Django apps:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Useful template tags:
'django.contrib.humanize',
# Admin panel and documentation:
'django.contrib.admin',
'waffle',
'compressor',
)
# Apps specific for this project go here.
LOCAL_APPS = (
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS
########## END APP CONFIGURATION
########## LOGGING CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
# 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,
},
}
}
########## END LOGGING CONFIGURATION
########## WSGI CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME
########## END WSGI CONFIGURATION
########## SEGMENT.IO
# 'None' disables tracking. This will be turned on for test and production.
SEGMENT_IO_KEY = None
# Regular expression used to identify users that should be ignored in reporting.
# This value will be compiled and should be either a string (e.g. when importing with YAML) or
# a Python regex type.
SEGMENT_IGNORE_EMAIL_REGEX = None
########## END SEGMENT.IO
########## FEEDBACK AND SUPPORT -- These values should be overridden for production deployments.
FEEDBACK_EMAIL = 'override.this.email@example.com'
SUPPORT_URL = 'http://example.com/'
PRIVACY_POLICY_URL = 'http://example.com/'
TERMS_OF_SERVICE_URL = 'http://example.com/'
HELP_URL = None
########## END FEEDBACK
########## LANDING PAGE -- URLs should be overridden for production deployments.
SHOW_LANDING_RESEARCH = True
RESEARCH_URL = 'http://example.com/'
OPEN_SOURCE_URL = 'http://example.com/'
########## END FEEDBACK
########## DOCUMENTATION LINKS -- These values should be overridden for production deployments.
DOCUMENTATION_LOAD_ERROR_URL = 'http://example.com/'
# evaluated again at the end of production setting after DOCUMENTATION_LOAD_ERROR_URL has been set
DOCUMENTATION_LOAD_ERROR_MESSAGE = '<a href="{error_documentation_link}" target="_blank">Read more</a>.'.format(error_documentation_link=DOCUMENTATION_LOAD_ERROR_URL)
########## END FEEDBACK
# The application and platform display names to be used in templates, emails, etc.
PLATFORM_NAME = 'Your Platform Name Here'
########## DOCS/HELP CONFIGURATION
DOCS_ROOT = join(dirname(SITE_ROOT), 'docs')
# Load the docs config into memory when the server starts
with open(join(DOCS_ROOT, "config.ini")) as config_file:
DOCS_CONFIG = ConfigParser.ConfigParser()
DOCS_CONFIG.readfp(config_file)
########## END DOCS/HELP CONFIGURATION
########## THEME CONFIGURATION
# Path of the SCSS file to use for the site's theme
THEME_SCSS = 'sass/themes/open-edx.scss'
########## END THEME CONFIGURATION
"""Development settings and globals."""
from __future__ import absolute_import
import os
from os.path import join, normpath
from settings.base import *
from settings.logger import get_logger_config
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
########## EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
########## END EMAIL CONFIGURATION
########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': normpath(join(DJANGO_ROOT, 'default.db')),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
########## END DATABASE CONFIGURATION
########## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
########## END CACHE CONFIGURATION
########## TOOLBAR CONFIGURATION
# See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup
if os.environ.get('ENABLE_DJANGO_TOOLBAR', False):
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
DEBUG_TOOLBAR_PATCH_SETTINGS = False
# http://django-debug-toolbar.readthedocs.org/en/latest/installation.html
INTERNAL_IPS = ('127.0.0.1',)
########## END TOOLBAR CONFIGURATION
INSTALLED_APPS += (
'django_nose',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
LMS_COURSE_SHORTCUT_BASE_URL = 'https://courses.edx.org/courses'
########## BRANDING
PLATFORM_NAME = 'edX'
########## END BRANDING
########## SEGMENT.IO
# 'None' disables tracking. This will be turned on for test and production.
SEGMENT_IO_KEY = os.environ.get('SEGMENT_WRITE_KEY')
########## END SEGMENT.IO
LOGGING = get_logger_config(debug=DEBUG, dev_env=True, local_loglevel='DEBUG')
"""Logging configuration"""
import os
import platform
import sys
from logging.handlers import SysLogHandler
def get_logger_config(log_dir='/var/tmp',
logging_env="no_env",
edx_filename="edx.log",
dev_env=False,
debug=False,
local_loglevel='INFO',
service_variant='edx-ecommerce'):
"""
Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings.
If dev_env is set to true logging will not be done via local rsyslogd,
instead, application logs will be dropped in log_dir.
"edx_filename" is ignored unless dev_env is set to true since otherwise logging is handled by rsyslogd.
"""
# Revert to INFO if an invalid string is passed in
if local_loglevel not in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
local_loglevel = 'INFO'
hostname = platform.node().split(".")[0]
syslog_format = ("[service_variant={service_variant}]"
"[%(name)s][env:{logging_env}] %(levelname)s "
"[{hostname} %(process)d] [%(filename)s:%(lineno)d] "
"- %(message)s").format(
service_variant=service_variant,
logging_env=logging_env, hostname=hostname)
if debug:
handlers = ['console']
else:
handlers = ['local']
logger_config = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(process)d '
'[%(name)s] %(filename)s:%(lineno)d - %(message)s',
},
'syslog_format': {'format': syslog_format},
'raw': {'format': '%(message)s'},
},
'handlers': {
'console': {
'level': 'DEBUG' if debug else 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'standard',
'stream': sys.stdout,
},
},
'loggers': {
'django': {
'handlers': handlers,
'propagate': True,
'level': 'INFO'
},
'': {
'handlers': handlers,
'level': 'DEBUG',
'propagate': False
},
}
}
if dev_env:
edx_file_loc = os.path.join(log_dir, edx_filename)
logger_config['handlers'].update({
'local': {
'class': 'logging.handlers.RotatingFileHandler',
'level': local_loglevel,
'formatter': 'standard',
'filename': edx_file_loc,
'maxBytes': 1024 * 1024 * 2,
'backupCount': 5,
},
})
else:
logger_config['handlers'].update({
'local': {
'level': local_loglevel,
'class': 'logging.handlers.SysLogHandler',
# Use a different address for Mac OS X
'address': '/var/run/syslog' if sys.platform == "darwin" else '/dev/log',
'formatter': 'syslog_format',
'facility': SysLogHandler.LOG_LOCAL0,
},
})
return logger_config
"""Production settings and globals."""
from os import environ
# Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured
import yaml
from settings.base import *
from settings.logger import get_logger_config
# Enable offline compression of CSS/JS
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
# Minify CSS
COMPRESS_CSS_FILTERS += [
'compressor.filters.cssmin.CSSMinFilter',
]
LOGGING = get_logger_config()
def get_env_setting(setting):
""" Get the environment setting or return exception """
try:
return environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg)
# ######### HOST CONFIGURATION
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production
ALLOWED_HOSTS = ['*']
########## END HOST CONFIGURATION
CONFIG_FILE = get_env_setting('EDX_ECOMMERCE_CFG')
with open(CONFIG_FILE) as f:
config_from_yaml = yaml.load(f)
vars().update(config_from_yaml)
DB_OVERRIDES = dict(
PASSWORD=environ.get('DB_MIGRATION_PASS', DATABASES['default']['PASSWORD']),
ENGINE=environ.get('DB_MIGRATION_ENGINE', DATABASES['default']['ENGINE']),
USER=environ.get('DB_MIGRATION_USER', DATABASES['default']['USER']),
NAME=environ.get('DB_MIGRATION_NAME', DATABASES['default']['NAME']),
HOST=environ.get('DB_MIGRATION_HOST', DATABASES['default']['HOST']),
PORT=environ.get('DB_MIGRATION_PORT', DATABASES['default']['PORT']),
)
for override, value in DB_OVERRIDES.iteritems():
DATABASES['default'][override] = value
# Re-declare the full application name in case the components have been overridden.
FULL_APPLICATION_NAME = '{0} {1}'.format(PLATFORM_NAME, APPLICATION_NAME)
# Depends on DOCUMENTATION_LOAD_ERROR_URL, so evaluate at the end
DOCUMENTATION_LOAD_ERROR_MESSAGE = 'This data may not be available for your course. ' \
'<a href="{error_documentation_link}" target="_blank">Read more</a>.'.format(error_documentation_link=DOCUMENTATION_LOAD_ERROR_URL)
from __future__ import absolute_import
from settings.base import *
########## TEST SETTINGS
INSTALLED_APPS += (
'django_nose',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
########## IN-MEMORY TEST DATABASE
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
},
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment