common.py 28.3 KB
Newer Older
1 2 3 4
"""
This is the common settings file, intended to set sane defaults. If you have a
piece of configuration that's dependent on a set of feature flags being set,
then create a function that returns the calculated value based on the value of
5
MITX_FEATURES[...]. Modules that extend this one can change the feature
6 7 8
configuration in an environment specific config file and re-calculate those
values.

9
We should make a method that calls all these config methods so that you just
10
make one call at the end of your site-specific dev file to reset all the
11 12
dependent variables (like INSTALLED_APPS) for you.

13
Longer TODO:
14
1. Right now our treatment of static content in general and in particular
15 16 17
   course-specific static content is haphazard.
2. We should have a more disciplined approach to feature flagging, even if it
   just means that we stick them in a dict called MITX_FEATURES.
18
3. We need to handle configuration for multiple courses. This could be as
19 20
   multiple sites, but we do need a way to map their data assets.
"""
21 22 23

# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
24
# pylint: disable=W0401, W0611, W0614
25

26
import sys
27
import os
28

29 30
from path import path

31
from .discussionsettings import *
32

Calen Pennington committed
33 34 35
from lms.xblock.mixin import LmsBlockMixin
from xmodule.modulestore.inheritance import InheritanceMixin

36
################################### FEATURES ###################################
37 38 39
# The display name of the platform to be used in templates/emails/etc.
PLATFORM_NAME = "edX"

40
COURSEWARE_ENABLED = True
41
ENABLE_JASMINE = False
42

43 44
PERFSTATS = False

Arjun Singh committed
45 46 47 48
DISCUSSION_SETTINGS = {
    'MAX_COMMENT_DEPTH': 2,
}

49

50 51
# Features
MITX_FEATURES = {
Calen Pennington committed
52 53 54
    'SAMPLE': False,
    'USE_DJANGO_PIPELINE': True,
    'DISPLAY_HISTOGRAMS_TO_STAFF': True,
55 56
    'REROUTE_ACTIVATION_EMAIL': False,  # nonempty string = address for all activation emails
    'DEBUG_LEVEL': 0,  # 0 = lowest level, least verbose, 255 = max level, most verbose
57 58 59

    ## DO NOT SET TO True IN THIS FILE
    ## Doing so will cause all courses to be released on production
60
    'DISABLE_START_DATES': False,  # When True, all courses will be active, regardless of start date
61

62 63 64
    # When True, will only publicly list courses by the subdomain. Expects you
    # to define COURSE_LISTINGS, a dictionary mapping subdomains to lists of
    # course_ids (see dev_int.py for an example)
Calen Pennington committed
65
    'SUBDOMAIN_COURSE_LISTINGS': False,
66

67 68 69 70 71
    # When True, will override certain branding with university specific values
    # Expects a SUBDOMAIN_BRANDING dictionary that maps the subdomain to the
    # university to use for branding purposes
    'SUBDOMAIN_BRANDING': False,

72
    'FORCE_UNIVERSITY_DOMAIN': False,  # set this to the university domain to use, as an override to HTTP_HOST
73 74
                                        # set to None to do no university selection

Calen Pennington committed
75
    'ENABLE_TEXTBOOK': True,
76
    'ENABLE_DISCUSSION_SERVICE': True,
77
    # discussion home panel, which includes a subscription on/off setting for discussion digest emails.
78
    # this should remain off in production until digest notifications are online.
e0d committed
79
    'ENABLE_DISCUSSION_HOME_PANEL': False,
80

81
    'ENABLE_PSYCHOMETRICS': False,  # real-time psychometrics (eg item response theory analysis in instructor dashboard)
82

83
    'ENABLE_DJANGO_ADMIN_SITE': False,  # set true to enable django's admin site, even on prod (e.g. for course ops)
84 85
    'ENABLE_SQL_TRACKING_LOGS': False,
    'ENABLE_LMS_MIGRATION': False,
86
    'ENABLE_MANUAL_GIT_RELOAD': False,
87

88 89
    'ENABLE_MASQUERADE': True,  # allow course staff to change to student view of courseware

90
    'DISABLE_LOGIN_BUTTON': False,  # used in systems where login is automatic, eg MIT SSL
91

92 93 94
    # extrernal access methods
    'ACCESS_REQUIRE_STAFF_FOR_COURSE': False,
    'AUTH_USE_OPENID': False,
Calen Pennington committed
95
    'AUTH_USE_MIT_CERTIFICATES': False,
96
    'AUTH_USE_OPENID_PROVIDER': False,
97
    'AUTH_USE_SHIB': False,
98
    'AUTH_USE_CAS': False,
99 100 101 102

    # This flag disables the requirement of having to agree to the TOS for users registering
    # with Shib.  Feature was requested by Stanford's office of general counsel
    'SHIB_DISABLE_TOS': False,
103

104 105
    # Enables ability to restrict enrollment in specific courses by the user account login method
    'RESTRICT_ENROLL_BY_REG_METHOD': False,
106 107

    # analytics experiments
108
    'ENABLE_INSTRUCTOR_ANALYTICS': False,
109

110 111
    'ENABLE_INSTRUCTOR_EMAIL': False,

112
    # enable analytics server.
113 114
    # WARNING: THIS SHOULD ALWAYS BE SET TO FALSE UNDER NORMAL
    # LMS OPERATION. See analytics.py for details about what
115
    # this does.
116

117
    'RUN_AS_ANALYTICS_SERVER_ENABLED': False,
118

119 120
    # Flip to True when the YouTube iframe API breaks (again)
    'USE_YOUTUBE_OBJECT_API': False,
121

122
    # Give a UI to show a student's submission history in a problem by the
123
    # Staff Debug tool.
124 125
    'ENABLE_STUDENT_HISTORY_VIEW': True,

126
    # segment.io for LMS--need to explicitly turn it on for production.
127 128
    'SEGMENT_IO_LMS': False,

129
    # Enables the student notes API and UI.
130 131
    'ENABLE_STUDENT_NOTES': True,

132 133
    # Provide a UI to allow users to submit feedback from the LMS
    'ENABLE_FEEDBACK_SUBMISSION': False,
Ned Batchelder committed
134

135 136 137
    # Turn on a page that lets staff enter Python code to be run in the
    # sandbox, for testing whether it's enabled properly.
    'ENABLE_DEBUG_RUN_PYTHON': False,
138 139 140

    # Enable URL that shows information about the status of variuous services
    'ENABLE_SERVICE_STATUS': False,
141 142

    # Toggle to indicate use of a custom theme
143 144 145
    'USE_CUSTOM_THEME': False,

    # Do autoplay videos for students
146 147
    'AUTOPLAY_VIDEOS': True,

148 149
    # Enable instructor dash to submit background tasks
    'ENABLE_INSTRUCTOR_BACKGROUND_TASKS': True,
150

151
    # Enable instructor dash beta version link
Miles Steele committed
152
    'ENABLE_INSTRUCTOR_BETA_DASHBOARD': True,
153

154 155
    # Allow use of the hint managment instructor view.
    'ENABLE_HINTER_INSTRUCTOR_VIEW': False,
156

157
    # for load testing
158
    'AUTOMATIC_AUTH_FOR_TESTING': False,
159

160 161
    # Toggle to enable chat availability (configured on a per-course
    # basis in Studio)
162
    'ENABLE_CHAT': False,
163 164

    # Allow users to enroll with methods other than just honor code certificates
David Ormsbee committed
165
    'MULTIPLE_ENROLLMENT_ROLES' : False,
166

167
    # Toggle the availability of the shopping cart page
David Ormsbee committed
168
    'ENABLE_SHOPPING_CART': False,
169 170

    # Toggle storing detailed billing information
171
    'STORE_BILLING_INFO': False,
172 173
}

174 175 176 177 178 179
# Used for A/B testing
DEFAULT_GROUPS = []

# If this is true, random scores will be generated for the purpose of debugging the profile graphs
GENERATE_PROFILE_SCORES = False

180
# Used with XQueue
181
XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5  # seconds
182

183

184
############################# SET PATH INFORMATION #############################
185
PROJECT_ROOT = path(__file__).abspath().dirname().dirname()  # /edx-platform/lms
186 187 188
REPO_ROOT = PROJECT_ROOT.dirname()
COMMON_ROOT = REPO_ROOT / "common"
ENV_ROOT = REPO_ROOT.dirname()  # virtualenv dir /mitx is in
189 190 191 192
COURSES_ROOT = ENV_ROOT / "data"

DATA_DIR = COURSES_ROOT

193
sys.path.append(REPO_ROOT)
194 195
sys.path.append(PROJECT_ROOT / 'djangoapps')
sys.path.append(PROJECT_ROOT / 'lib')
196
sys.path.append(COMMON_ROOT / 'djangoapps')
197
sys.path.append(COMMON_ROOT / 'lib')
198

199
# For Node.js
200

201
system_node_path = os.environ.get("NODE_PATH", REPO_ROOT / 'node_modules')
202

203
node_paths = [COMMON_ROOT / "static/js/vendor",
204 205
              COMMON_ROOT / "static/coffee/src",
              system_node_path
206
              ]
207
NODE_PATH = ':'.join(node_paths)
208

209

210
# Where to look for a status message
211
STATUS_MESSAGE_PATH = ENV_ROOT / "status_message.json"
212

213
############################ OpenID Provider  ##################################
214
OPENID_PROVIDER_TRUSTED_ROOTS = ['cs50.net', '*.cs50.net']
215

216
################################## MITXWEB #####################################
217 218
# This is where we stick our compiled template files. Most of the app uses Mako
# templates
219 220
from tempdir import mkdtemp_clean
MAKO_MODULE_DIR = mkdtemp_clean('mako')
Piotr Mitros committed
221
MAKO_TEMPLATES = {}
222
MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates',
223
                          COMMON_ROOT / 'templates',
224
                          COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
225
                          COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates']
Piotr Mitros committed
226

227
# This is where Django Template lookup is defined. There are a few of these
228
# still left lying around.
229
TEMPLATE_DIRS = [
230
    PROJECT_ROOT / "templates",
231 232 233
    COMMON_ROOT / 'templates',
    COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
    COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
234
]
235 236 237

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
238
    'django.core.context_processors.static',
239
    'django.contrib.messages.context_processors.messages',
240
    #'django.core.context_processors.i18n',
241
    'django.contrib.auth.context_processors.auth',  # this is required for admin
242
    'django.core.context_processors.csrf',
243

244 245 246 247 248
    # Added for django-wiki
    'django.core.context_processors.media',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'sekizai.context_processors.sekizai',
249
    'course_wiki.course_nav.context_processor',
250 251 252

    # Hack to get required link URLs to password reset templates
    'mitxmako.shortcuts.marketing_link_context_processor',
253 254
)

Diana Huang committed
255 256 257 258
# use the ratelimit backend to prevent brute force attacks
AUTHENTICATION_BACKENDS = (
    'ratelimitbackend.backends.RateLimitModelBackend',
)
259
STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000  # 4 MB
260
MAX_FILEUPLOADS_PER_INPUT = 20
261

262 263
# FIXME:
# We should have separate S3 staged URLs in case we need to make changes to
264
# these assets and test them.
265
LIB_URL = '/static/js/'
266 267 268

# Dev machines shouldn't need the book
# BOOK_URL = '/static/book/'
269
BOOK_URL = 'https://mitxstatic.s3.amazonaws.com/book_images/'  # For AWS deploys
270
# RSS_URL = r'lms/templates/feed.rss'
271
# PRESS_URL = r''
272
RSS_TIMEOUT = 600
273

274 275 276 277
# Configuration option for when we want to grab server error pages
STATIC_GRAB = False
DEV_CONTENT = True

278
# FIXME: Should we be doing this truncation?
279
TRACK_MAX_EVENT = 10000
280
DEBUG_TRACK_LOG = False
281

282 283
MITX_ROOT_URL = ''

284 285 286
LOGIN_REDIRECT_URL = MITX_ROOT_URL + '/accounts/login'
LOGIN_URL = MITX_ROOT_URL + '/accounts/login'

287 288 289 290
COURSE_NAME = "6.002_Spring_2012"
COURSE_NUMBER = "6.002x"
COURSE_TITLE = "Circuits and Electronics"

291
### Dark code. Should be enabled in local settings for devel.
292

293
ENABLE_MULTICOURSE = False  # set to False to disable multicourse display (see lib.util.views.mitxhome)
294

295 296
WIKI_ENABLED = False

297 298
###

299
COURSE_DEFAULT = '6.002x_Fall_2012'
Adam Palay committed
300 301 302 303 304 305 306 307
COURSE_SETTINGS = {
    '6.002x_Fall_2012': {
        'number': '6.002x',
        'title': 'Circuits and Electronics',
        'xmlpath': '6002x/',
        'location': 'i4x://edx/6002xs12/course/6.002x_Fall_2012',
    }
}
308

Victor Shnayder committed
309 310 311
# IP addresses that are allowed to reload the course, etc.
# TODO (vshnayder): Will probably need to change as we get real access control in.
LMS_MIGRATION_ALLOWED_IPS = []
312

313 314 315 316 317
######################## subdomain specific settings ###########################
COURSE_LISTINGS = {}
SUBDOMAIN_BRANDING = {}


318
############################### XModule Store ##################################
319
MODULESTORE = {
320
    'default': {
321
        'ENGINE': 'xmodule.modulestore.xml.XMLModuleStore',
322 323 324 325 326 327
        'OPTIONS': {
            'data_dir': DATA_DIR,
            'default_class': 'xmodule.hidden_module.HiddenDescriptor',
        }
    }
}
328
CONTENTSTORE = None
329

Calen Pennington committed
330 331 332 333 334 335
############# XBlock Configuration ##########

# This should be moved into an XBlock Runtime/Application object
# once the responsibility of XBlock creation is moved out of modulestore - cpennington
XBLOCK_MIXINS = (LmsBlockMixin, InheritanceMixin)

336 337 338 339 340 341 342
#################### Python sandbox ############################################

CODE_JAIL = {
    # Path to a sandboxed Python executable.  None means don't bother.
    'python_bin': None,
    # User to run as in the sandbox.
    'user': 'sandbox',
343 344 345 346 347 348

    # Configurable limits.
    'limits': {
        # How many CPU seconds can jailed code use?
        'CPU': 1,
    },
349 350
}

351 352 353 354 355 356 357 358 359
# Some courses are allowed to run unsafe code. This is a list of regexes, one
# of them must match the course id for that course to run unsafe code.
#
# For example:
#
#   COURSES_WITH_UNSAFE_CODE = [
#       r"Harvard/XY123.1/.*"
#   ]
COURSES_WITH_UNSAFE_CODE = []
360

361 362 363
############################ SIGNAL HANDLERS ################################
# This is imported to register the exception signal handling that logs exceptions
import monitoring.exceptions  # noqa
364

365 366 367 368
############################### DJANGO BUILT-INS ###############################
# Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here
DEBUG = False
TEMPLATE_DEBUG = False
369
USE_TZ = True
370

371 372 373
# CMS base
CMS_BASE = 'localhost:8001'

374 375
# Site info
SITE_ID = 1
376
SITE_NAME = "edx.org"
377
HTTPS = 'on'
378
ROOT_URLCONF = 'lms.urls'
379
IGNORABLE_404_ENDS = ('favicon.ico')
380

381
# Email
382
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
383
DEFAULT_FROM_EMAIL = 'registration@edx.org'
384
DEFAULT_BULK_FROM_EMAIL = 'course-updates@edx.org'
385 386
EMAILS_PER_TASK = 100
EMAILS_PER_QUERY = 1000
387
DEFAULT_FEEDBACK_EMAIL = 'feedback@edx.org'
388
SERVER_EMAIL = 'devops@edx.org'
389
TECH_SUPPORT_EMAIL = 'technical@edx.org'
390 391
CONTACT_EMAIL = 'info@edx.org'
BUGS_EMAIL = 'bugs@edx.org'
392
ADMINS = ()
393 394
MANAGERS = ADMINS

395
# Static content
396 397
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
398
STATIC_ROOT = ENV_ROOT / "staticfiles"
399

400
STATICFILES_DIRS = [
401
    COMMON_ROOT / "static",
402
    PROJECT_ROOT / "static",
403
]
404

405 406
FAVICON_PATH = 'images/favicon.ico'

407
# Locale/Internationalization
408 409
TIME_ZONE = 'America/New_York'  # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
LANGUAGE_CODE = 'en'  # http://www.i18nguy.com/unicode/language-identifiers.html
Adam Palay committed
410
USE_I18N = False
411
USE_L10N = True
412

413 414
# Localization strings (e.g. django.po) are under this directory
LOCALE_PATHS = (REPO_ROOT + '/conf/locale',)  # edx-platform/conf/locale/
415 416 417
# Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

418 419 420 421 422 423
#################################### GITHUB #######################################
# gitreload is used in LMS-workflow to pull content from github
# gitreload requests are only allowed from these IP addresses, which are
# the advertised public IPs of the github WebHook servers.
# These are listed, eg at https://github.com/MITx/mitx/admin/hooks

424
ALLOWED_GITRELOAD_IPS = ['207.97.227.253', '50.57.128.197', '108.171.174.178']
425

426
#################################### AWS #######################################
427
# S3BotoStorage insists on a timeout for uploaded assets. We should make it
428
# permanent instead, but rather than trying to figure out exactly where that
429
# setting is, I'm just bumping the expiration time to something absurd (100
430 431
# years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3
# in the global settings.py
432
AWS_QUERYSTRING_EXPIRE = 10 * 365 * 24 * 60 * 60  # 10 years
433

434
################################# SIMPLEWIKI ###################################
435 436
SIMPLE_WIKI_REQUIRE_LOGIN_EDIT = True
SIMPLE_WIKI_REQUIRE_LOGIN_VIEW = False
437

438 439
################################# WIKI ###################################
WIKI_ACCOUNT_HANDLING = False
440
WIKI_EDITOR = 'course_wiki.editors.CodeMirror'
441 442
WIKI_SHOW_MAX_CHILDREN = 0  # We don't use the little menu that shows children of an article in the breadcrumb
WIKI_ANONYMOUS = False  # Don't allow anonymous access until the styling is figured out
443 444 445 446
WIKI_CAN_CHANGE_PERMISSIONS = lambda article, user: user.is_staff or user.is_superuser
WIKI_CAN_ASSIGN = lambda article, user: user.is_staff or user.is_superuser

WIKI_USE_BOOTSTRAP_SELECT_WIDGET = False
447
WIKI_LINK_LIVE_LOOKUPS = False
448
WIKI_LINK_DEFAULT_LEVEL = 2
449

450 451 452
################################# Pearson TestCenter config  ################

PEARSONVUE_SIGNINPAGE_URL = "https://www1.pearsonvue.com/testtaker/signin/SignInPage/EDX"
453
# TESTCENTER_ACCOMMODATION_REQUEST_EMAIL = "exam-help@edx.org"
454

455 456 457 458 459 460 461 462
##### Feedback submission mechanism #####
FEEDBACK_SUBMISSION_EMAIL = None

##### Zendesk #####
ZENDESK_URL = None
ZENDESK_USER = None
ZENDESK_API_KEY = None

463
##### shoppingcart Payment #####
464
PAYMENT_SUPPORT_EMAIL = 'payment@edx.org'
465 466
##### Using cybersource by default #####
CC_PROCESSOR = {
467
    'CyberSource': {
468
        'SHARED_SECRET': '',
469 470
        'MERCHANT_ID': '',
        'SERIAL_NUMBER': '',
471 472 473
        'ORDERPAGE_VERSION': '7',
        'PURCHASE_ENDPOINT': '',
    }
474 475
}

476
################################# open ended grading config  #####################
477 478 479

#By setting up the default settings with an incorrect user name and password,
# will get an error when attempting to connect
480
OPEN_ENDED_GRADING_INTERFACE = {
481 482 483
    'url': 'http://sandbox-grader-001.m.edx.org/peer_grading',
    'username': 'incorrect_user',
    'password': 'incorrect_pass',
Diana Huang committed
484 485 486 487
    'staff_grading': 'staff_grading',
    'peer_grading': 'peer_grading',
    'grading_controller': 'grading_controller'
}
488

489
# Used for testing, debugging peer grading
490
MOCK_PEER_GRADING = False
491

492 493 494
# Used for testing, debugging staff grading
MOCK_STAFF_GRADING = False

495
################################# Jasmine ###################################
496
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
497

498 499 500 501
################################# Middleware ###################################
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
502 503
    'staticfiles.finders.FileSystemFinder',
    'staticfiles.finders.AppDirectoriesFinder',
504 505 506 507
)

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
508 509
    'mitxmako.makoloader.MakoFilesystemLoader',
    'mitxmako.makoloader.MakoAppDirectoriesLoader',
510

511 512
    # 'django.template.loaders.filesystem.Loader',
    # 'django.template.loaders.app_directories.Loader',
513

514 515 516
)

MIDDLEWARE_CLASSES = (
517
    'contentserver.middleware.StaticContentServer',
518
    'request_cache.middleware.RequestCache',
Rocky Duan committed
519
    'django_comment_client.middleware.AjaxExceptionMiddleware',
520 521
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
522 523

    # Instead of AuthenticationMiddleware, we use a cached backed version
524 525
    #'django.contrib.auth.middleware.AuthenticationMiddleware',
    'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
526

527 528 529
    'django.contrib.messages.middleware.MessageMiddleware',
    'track.middleware.TrackMiddleware',
    'mitxmako.middleware.MakoMiddleware',
530
    'django.middleware.csrf.CsrfViewMiddleware',
531

532
    'course_wiki.course_nav.Middleware',
533

534 535 536
    # Detects user-requested locale from 'accept-language' header in http request
    'django.middleware.locale.LocaleMiddleware',

537
    'django.middleware.transaction.TransactionMiddleware',
538
    # 'debug_toolbar.middleware.DebugToolbarMiddleware',
539 540

    'django_comment_client.utils.ViewNameMiddleware',
541
    'codejail.django_integration.ConfigureCodeJailMiddleware',
Diana Huang committed
542 543 544

    # catches any uncaught RateLimitExceptions and returns a 403 instead of a 500
    'ratelimitbackend.middleware.RateLimitMiddleware',
545 546
)

547 548 549 550
############################### Pipeline #######################################

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

551
from rooted_paths import rooted_glob
552

553 554
courseware_js = (
    [
555
        'coffee/src/' + pth + '.js'
556 557
        for pth in ['courseware', 'histogram', 'navigation', 'time']
    ] +
558
    sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/modules/**/*.js'))
559
)
560

561 562
# 'js/vendor/RequireJS.js' - Require JS wrapper.
# See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
563
main_vendor_js = [
564 565 566 567 568 569 570 571 572 573 574
    'js/vendor/RequireJS.js',
    'js/vendor/json2.js',
    'js/vendor/jquery.min.js',
    'js/vendor/jquery-ui.min.js',
    'js/vendor/jquery.cookie.js',
    'js/vendor/jquery.qtip.min.js',
    'js/vendor/swfobject/swfobject.js',
    'js/vendor/jquery.ba-bbq.min.js',
    'js/vendor/annotator.min.js',
    'js/vendor/annotator.store.min.js',
    'js/vendor/annotator.tags.min.js'
575
]
576

577 578 579
discussion_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/discussion/**/*.js'))
staff_grading_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/staff_grading/**/*.js'))
open_ended_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/open_ended/**/*.js'))
Arthur Barrett committed
580
notes_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/notes/**/*.coffee'))
581

582 583
PIPELINE_CSS = {
    'application': {
584
        'source_filenames': ['sass/application.css'],
585
        'output_filename': 'css/lms-application.css',
586
    },
Kyle Fiedler committed
587
    'course': {
588 589 590 591 592
        'source_filenames': [
            'js/vendor/CodeMirror/codemirror.css',
            'css/vendor/jquery.treeview.css',
            'css/vendor/ui-lightness/jquery-ui-1.8.22.custom.css',
            'css/vendor/jquery.qtip.min.css',
593
            'css/vendor/annotator.min.css',
594 595
            'sass/course.css',
            'xmodule/modules.css',
596 597 598
        ],
        'output_filename': 'css/lms-course.css',
    },
599
    'ie-fixes': {
600
        'source_filenames': ['sass/ie.css'],
601
        'output_filename': 'css/lms-ie.css',
602
    },
603
}
604

605 606 607

# test_order: Determines the position of this chunk of javascript on
# the jasmine test page
608 609
PIPELINE_JS = {
    'application': {
610

611
        # Application will contain all paths not in courseware_only_js
612
        'source_filenames': sorted(
613 614
            set(rooted_glob(COMMON_ROOT / 'static', 'coffee/src/**/*.js') +
                rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/**/*.js')) -
Arthur Barrett committed
615
            set(courseware_js + discussion_js + staff_grading_js + open_ended_js + notes_js)
616
        ) + [
617 618 619 620
            'js/form.ext.js',
            'js/my_courses_dropdown.js',
            'js/toggle_login_modal.js',
            'js/sticky_filter.js',
621
            'js/query-params.js',
622
            'js/src/utility.js',
623
        ],
624 625 626
        'output_filename': 'js/lms-application.js',

        'test_order': 1,
627
    },
628
    'courseware': {
629
        'source_filenames': courseware_js,
630 631
        'output_filename': 'js/lms-courseware.js',
        'test_order': 2,
632
    },
633 634
    'main_vendor': {
        'source_filenames': main_vendor_js,
635
        'output_filename': 'js/lms-main_vendor.js',
636
        'test_order': 0,
637
    },
638 639 640 641 642
    'module-descriptor-js': {
        'source_filenames': rooted_glob(COMMON_ROOT / 'static/', 'xmodule/descriptors/js/*.js'),
        'output_filename': 'js/lms-module-descriptors.js',
        'test_order': 8,
    },
643
    'module-js': {
644
        'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'),
645
        'output_filename': 'js/lms-modules.js',
646
        'test_order': 3,
647
    },
648 649
    'discussion': {
        'source_filenames': discussion_js,
650 651
        'output_filename': 'js/discussion.js',
        'test_order': 4,
652
    },
Calen Pennington committed
653
    'staff_grading': {
654
        'source_filenames': staff_grading_js,
655 656
        'output_filename': 'js/staff_grading.js',
        'test_order': 5,
657
    },
Calen Pennington committed
658
    'open_ended': {
659
        'source_filenames': open_ended_js,
660 661
        'output_filename': 'js/open_ended.js',
        'test_order': 6,
Arthur Barrett committed
662 663 664
    },
    'notes': {
        'source_filenames': notes_js,
665 666
        'output_filename': 'js/notes.js',
        'test_order': 7
Arthur Barrett committed
667
    },
668 669
}

670 671
PIPELINE_DISABLE_WRAPPER = True

672 673 674
# Compile all coffee files in course data directories if they are out of date.
# TODO: Remove this once we move data into Mongo. This is only temporary while
# course data directories are still in use.
675 676 677 678 679 680 681 682 683 684
if os.path.isdir(DATA_DIR):
    for course_dir in os.listdir(DATA_DIR):
        js_dir = DATA_DIR / course_dir / "js"
        if not os.path.isdir(js_dir):
            continue
        for filename in os.listdir(js_dir):
            if filename.endswith('coffee'):
                new_filename = os.path.splitext(filename)[0] + ".js"
                if os.path.exists(js_dir / new_filename):
                    coffee_timestamp = os.stat(js_dir / filename).st_mtime
685
                    js_timestamp = os.stat(js_dir / new_filename).st_mtime
686 687
                    if coffee_timestamp <= js_timestamp:
                        continue
688
                os.system("rm %s" % (js_dir / new_filename))
689 690
                os.system("coffee -c %s" % (js_dir / filename))

691 692

PIPELINE_CSS_COMPRESSOR = None
693
PIPELINE_JS_COMPRESSOR = None
694

695
STATICFILES_IGNORE_PATTERNS = (
696 697
    "sass/*",
    "coffee/*",
698 699
)

700
PIPELINE_YUI_BINARY = 'yui-compressor'
701

702 703 704
# Setting that will only affect the MITx version of django-pipeline until our changes are merged upstream
PIPELINE_COMPILE_INPLACE = True

705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
################################# CELERY ######################################

# Message configuration

CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

CELERY_MESSAGE_COMPRESSION = 'gzip'

# Results configuration

CELERY_IGNORE_RESULT = False
CELERY_STORE_ERRORS_EVEN_IF_IGNORED = True

# Events configuration

CELERY_TRACK_STARTED = True

CELERY_SEND_EVENTS = True
CELERY_SEND_TASK_SENT_EVENT = True

# Exchange configuration

CELERY_DEFAULT_EXCHANGE = 'edx.core'
CELERY_DEFAULT_EXCHANGE_TYPE = 'direct'

# Queues configuration

HIGH_PRIORITY_QUEUE = 'edx.core.high'
DEFAULT_PRIORITY_QUEUE = 'edx.core.default'
LOW_PRIORITY_QUEUE = 'edx.core.low'

CELERY_QUEUE_HA_POLICY = 'all'

CELERY_CREATE_MISSING_QUEUES = True

CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
CELERY_DEFAULT_ROUTING_KEY = DEFAULT_PRIORITY_QUEUE

CELERY_QUEUES = {
    HIGH_PRIORITY_QUEUE: {},
    LOW_PRIORITY_QUEUE: {},
    DEFAULT_PRIORITY_QUEUE: {}
}

################################### APPS ######################################
751 752 753 754 755 756 757 758
INSTALLED_APPS = (
    # Standard ones that are always installed...
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.messages',
    'django.contrib.sessions',
    'django.contrib.sites',
759
    'djcelery',
760 761
    'south',

762 763 764
    # Monitor the status of services
    'service_status',

765
    # For asset pipelining
766
    'mitxmako',
767 768
    'pipeline',
    'staticfiles',
769
    'static_replace',
770

771 772 773 774 775 776 777 778 779
    # Our courseware
    'circuit',
    'courseware',
    'perfstats',
    'student',
    'static_template_view',
    'staticbook',
    'track',
    'util',
780
    'certificates',
781
    'instructor',
782
    'instructor_task',
783
    'open_ended_grading',
784
    'psychometrics',
785
    'licenses',
786
    'course_groups',
787
    'bulk_email',
788

789 790 791 792
    # External auth (OpenID, shib)
    'external_auth',
    'django_openid_auth',

793
    #For the wiki
794
    'wiki',  # The new django-wiki from benjaoming
795
    'django_notify',
796
    'course_wiki',  # Our customizations
797 798
    'mptt',
    'sekizai',
799
    #'wiki.plugins.attachments',
800
    'wiki.plugins.links',
801
    'wiki.plugins.notifications',
802
    'course_wiki.plugins.markdownedx',
803

Victor Shnayder committed
804 805 806
    # foldit integration
    'foldit',

807
    # For testing
808
    'django.contrib.admin',  # only used in DEBUG mode
809
    'django_nose',
810
    'debug',
811

812
    # Discussion forums
813
    'django_comment_client',
814
    'django_comment_common',
815
    'notes',
816 817 818 819

    # User API
    'rest_framework',
    'user_api',
820

821 822 823
    # shopping cart
    'shoppingcart',

824 825
    # Notification preferences setting
    'notification_prefs',
826 827

    # Different Course Modes
828
    'course_modes',
829 830 831

    # Student Identity Verification
    'verify_student',
832
)
833

834 835
######################### MARKETING SITE ###############################
EDXMKTG_COOKIE_NAME = 'edxloggedin'
836
MKTG_URLS = {}
837 838 839 840 841 842
MKTG_URL_LINK_MAP = {
    'ABOUT': 'about_edx',
    'CONTACT': 'contact',
    'FAQ': 'help_edx',
    'COURSES': 'courses',
    'ROOT': 'root',
843 844 845
    'TOS': 'tos',
    'HONOR': 'honor',
    'PRIVACY': 'privacy_edx',
846 847 848

    # Verified Certificates
    'WHAT_IS_VERIFIED_CERT' : 'verified-certificate',
849
}
850

851

852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
############################### THEME ################################
def enable_theme(theme_name):
    """
    Enable the settings for a custom theme, whose files should be stored
    in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford).

    The THEME_NAME setting should be configured separately since it can't
    be set here (this function closes too early). An idiom for doing this
    is:

    THEME_NAME = "stanford"
    enable_theme(THEME_NAME)
    """
    MITX_FEATURES['USE_CUSTOM_THEME'] = True

    # Calculate the location of the theme's files
    theme_root = ENV_ROOT / "themes" / theme_name

    # Include the theme's templates in the template search paths
    TEMPLATE_DIRS.append(theme_root / 'templates')
    MAKO_TEMPLATES['main'].append(theme_root / 'templates')

    # Namespace the theme's static files to 'themes/<theme_name>' to
    # avoid collisions with default edX static files
    STATICFILES_DIRS.append((u'themes/%s' % theme_name,
                             theme_root / 'static'))
878 879 880 881 882

################# Student Verification #################
VERIFY_STUDENT = {
    "DAYS_GOOD_FOR" : 365, # How many days is a verficiation good for?
}
883

884 885 886 887 888 889 890
######################## CAS authentication ###########################

if MITX_FEATURES.get('AUTH_USE_CAS'):
    CAS_SERVER_URL = 'https://provide_your_cas_url_here'
    AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.ModelBackend',
        'django_cas.backends.CASBackend',
891
    )
892 893
    INSTALLED_APPS += ('django_cas',)
    MIDDLEWARE_CLASSES += ('django_cas.middleware.CASMiddleware',)