Skip to content
Snippets Groups Projects
common.py 145 KiB
Newer Older
# -*- coding: utf-8 -*-
"""
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
FEATURES[...]. Modules that extend this one can change the feature
configuration in an environment specific config file and re-calculate those
values.

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

Longer TODO:
1. Right now our treatment of static content in general and in particular
   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 FEATURES.
3. We need to handle configuration for multiple courses. This could be as
   multiple sites, but we do need a way to map their data assets.
"""
# We intentionally define lots of variables that aren't used
# pylint: disable=unused-import
# Pylint gets confused by path.py instances, which report themselves as class
# objects. As a result, pylint applies the wrong regex in validating names,
# and throws spurious errors. Therefore, we disable invalid-name checking.
# pylint: disable=invalid-name
import importlib.util
from corsheaders.defaults import default_headers as corsheaders_default_headers
from path import Path as path
from django.utils.translation import ugettext_lazy as _
from enterprise.constants import (
    ENTERPRISE_ADMIN_ROLE,
    ENTERPRISE_CATALOG_ADMIN_ROLE,
    ENTERPRISE_DASHBOARD_ADMIN_ROLE,
    ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE,
    ENTERPRISE_REPORTING_CONFIG_ADMIN_ROLE,
Bill DeRusha's avatar
Bill DeRusha committed
from openedx.core.constants import COURSE_KEY_REGEX, COURSE_KEY_PATTERN, COURSE_ID_PATTERN
from openedx.core.djangoapps.theming.helpers_dirs import (
    get_themes_unchecked,
    get_theme_base_dirs_from_settings
)
from openedx.core.lib.derived import derived, derived_collection_entry
from openedx.core.release import doc_version
from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
Calen Pennington's avatar
Calen Pennington committed

################################### FEATURES ###################################
# .. setting_name: PLATFORM_NAME
# .. setting_default: Your Platform Name Here
# .. setting_description: The display name of the platform to be used in
#     templates/emails/etc.
PLATFORM_NAME = _('Your Platform Name Here')
PLATFORM_DESCRIPTION = _('Your Platform Description Here')
CC_MERCHANT_NAME = PLATFORM_NAME
PLATFORM_FACEBOOK_ACCOUNT = "http://www.facebook.com/YourPlatformFacebookAccount"
PLATFORM_TWITTER_ACCOUNT = "@YourPlatformTwitterAccount"
nadeemshahzad's avatar
nadeemshahzad committed
LMS_ROOT_URL = 'https://localhost:18000'
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
LMS_ENROLLMENT_API_PATH = "/api/enrollment/v1/"
# Default choices for role dropdown in the membership tab of the instructor dashboard
# This setting is used when a site does not define its own choices via site configuration
MANUAL_ENROLLMENT_ROLE_CHOICES = ['Learner', 'Support', 'Partner']

# List of logout URIs for each IDA that the learner should be logged out of when they logout of the LMS. Only applies to
# IDA for which the social auth flow uses DOT (Django OAuth Toolkit).
IDA_LOGOUT_URI_LIST = []

# Features
    # .. toggle_name: DISPLAY_DEBUG_INFO_TO_STAFF
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: Add a "Staff Debug" button to course modules for debugging
    #   by course staff.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2015-09-04
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/2425
    'DISPLAY_DEBUG_INFO_TO_STAFF': True,
    'DISPLAY_HISTOGRAMS_TO_STAFF': False,  # For large courses this slows down courseware access for staff.
    'REROUTE_ACTIVATION_EMAIL': False,  # nonempty string = address for all activation emails
    # .. toggle_name: DISABLE_START_DATES
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: When True, all courses will be active, regardless of start
    #   date.
    # .. toggle_use_cases: open_edx
    # .. toggle_warnings: This will cause ALL courses to be immediately visible.
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/17913
    ## DO NOT SET TO True IN THIS FILE
    ## Doing so will cause all courses to be released on production
    'DISABLE_START_DATES': False,
    # for consistency in user-experience, keep the value of the following 3 settings
    # in sync with the corresponding ones in cms/envs/common.py
    'ENABLE_DISCUSSION_SERVICE': True,

    # .. toggle_name: ENABLE_TEXTBOOK
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: Add PDF and HTML textbook tabs to the courseware.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-03-27
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/3064
    'ENABLE_TEXTBOOK': True,
    # discussion home panel, which includes a subscription on/off setting for discussion digest emails.
    # this should remain off in production until digest notifications are online.
e0d's avatar
e0d committed
    'ENABLE_DISCUSSION_HOME_PANEL': False,
    # .. toggle_name: ENABLE_DISCUSSION_EMAIL_DIGEST
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set this to True if you want the discussion digest emails
    #   enabled automatically for new users. This will be set on all new account
    #   registrations.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-08-19
    # .. toggle_warnings: It is not recommended to enable this feature if ENABLE_DISCUSSION_HOME_PANEL is not enabled,
    #   since subscribers who receive digests in that case will only be able to unsubscribe via links embedded in
    #   their emails, and they will have no way to resubscribe.
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/4891
    # .. toggle_name: ENABLE_UNICODE_USERNAME
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set this to True to allow unicode characters in username. Enabling this will also
    #   automatically enable SOCIAL_AUTH_CLEAN_USERNAMES. When this is enabled, usernames will have to match the
    #   regular expression defined by USERNAME_REGEX_PARTIAL.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2017-06-27
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/14729
    'ENABLE_UNICODE_USERNAME': False,

    'ENABLE_DJANGO_ADMIN_SITE': True,  # set true to enable django's admin site, even on prod (e.g. for course ops)
    'ENABLE_LMS_MIGRATION': False,

    # .. toggle_name: ENABLE_MASQUERADE
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2013-04-13
    'ENABLE_MASQUERADE': True,
    # .. toggle_name: ENABLE_SYSADMIN_DASHBOARD
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: enables dashboard at /syadmin/ for django staff, for seeing overview of system status, for
    #   deleting and loading courses, for seeing log of git imports of courseware. Note that some views are noopen_edx
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2013-12-12
    # .. toggle_target_removal_date: None
    # .. toggle_warnings: This feature is not supported anymore and should have a target removal date.
Carson Gee's avatar
Carson Gee committed
    'ENABLE_SYSADMIN_DASHBOARD': False,  # sysadmin dashboard, to see what courses are loaded, to delete & load courses

    'DISABLE_LOGIN_BUTTON': False,  # used in systems where login is automatic, eg MIT SSL
    # .. toggle_name: ENABLE_OAUTH2_PROVIDER
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Enable this feature to allow this Open edX platform to be an OAuth2 authentication
    #   provider. This is necessary to enable some other features, such as the REST API for the mobile application.
    # .. toggle_use_cases: temporary
    # .. toggle_creation_date: 2014-09-09
    # .. toggle_target_removal_date: None
    # .. toggle_warnings: This temporary feature toggle does not have a target removal date.
    'ENABLE_OAUTH2_PROVIDER': False,

    # .. toggle_name: ENABLE_XBLOCK_VIEW_ENDPOINT
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Enable an API endpoint, named "xblock_view", to serve rendered XBlock views. This might be
    #   used by external applications. See for instance jquery-xblock (now unmaintained):
    #   https://github.com/edx-solutions/jquery-xblock
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-03-14
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/2968
    'ENABLE_XBLOCK_VIEW_ENDPOINT': False,

    # Allows to configure the LMS to provide CORS headers to serve requests from other
    # domains
    # Can be turned off if course lists need to be hidden. Effects views and templates.
    'COURSES_ARE_BROWSABLE': True,
    # Set to hide the courses list on the Learner Dashboard if they are not enrolled in
    # any courses yet.
    'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED': False,

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

    # 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,

    # Enable URL that shows information about the status of variuous services
    'ENABLE_SERVICE_STATUS': False,
    # Don't autoplay videos for students
    'AUTOPLAY_VIDEOS': False,
    # Move the student to next page when a video finishes. Set to True to show
    # an auto-advance button in videos. If False, videos never auto-advance.
    'ENABLE_AUTOADVANCE_VIDEOS': False,

    # Enable instructor dash to submit background tasks
    'ENABLE_INSTRUCTOR_BACKGROUND_TASKS': True,
    # Enable instructor to assign individual due dates
    # Note: In order for this feature to work, you must also add
    # 'lms.djangoapps.courseware.student_field_overrides.IndividualStudentOverrideProvider' to
    # the setting FIELD_OVERRIDE_PROVIDERS, in addition to setting this flag to
    # True.
    'INDIVIDUAL_DUE_DATES': False,

cewing's avatar
cewing committed
    # Enable Custom Courses for EdX
    'CUSTOM_COURSES_EDX': False,
    # Toggle to enable certificates of courses on dashboard
    'ENABLE_VERIFIED_CERTIFICATES': False,

    # .. toggle_name: DISABLE_HONOR_CERTIFICATES
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set to True to disable honor certificates. Typically used when your installation only
    #   allows verified certificates, like courses.edx.org.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2019-05-14
    # .. toggle_tickets: https://openedx.atlassian.net/browse/PROD-269
    'DISABLE_HONOR_CERTIFICATES': False,  # Toggle to disable honor certificates

    'DISABLE_AUDIT_CERTIFICATES': False,  # Toggle to disable audit certificates

    # for acceptance and load testing
    'AUTOMATIC_AUTH_FOR_TESTING': False,
    # .. toggle_name: RESTRICT_AUTOMATIC_AUTH
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: Prevent auto auth from creating superusers or modifying existing users. Auto auth is a
    #   mechanism where superusers can simply modify attributes of other users by accessing the "/auto_auth url" with
    #   the right
    #   querystring parameters.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2018-05-07
    # .. toggle_tickets: https://openedx.atlassian.net/browse/TE-2545
    'RESTRICT_AUTOMATIC_AUTH': True,

    # .. toggle_name: ENABLE_LOGIN_MICROFRONTEND
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Enable the login micro frontend.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2018-05-07
    # .. toggle_warnings: The login MFE domain name should be listed in LOGIN_REDIRECT_WHITELIST.
    'ENABLE_LOGIN_MICROFRONTEND': False,

    # .. toggle_name: SKIP_EMAIL_VALIDATION
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Turn this on to skip sending emails for user validation.
    #   Beware, as this leaves the door open to potential spam abuse.
    # .. toggle_use_cases: open_edx
    # .. toggle_warnings: The login MFE domain name should be listed in LOGIN_REDIRECT_WHITELIST.
    'SKIP_EMAIL_VALIDATION': False,

    # .. toggle_name: ENABLE_COSMETIC_DISPLAY_PRICE
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Enable the display of "cosmetic_display_price", set in a course advanced settings. This
    #   cosmetic price is used when there is no registration price associated to the course.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-10-10
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/6876
    # .. toggle_warnings: The use case of this feature toggle is uncertain.
    'ENABLE_COSMETIC_DISPLAY_PRICE': False,

    # Automatically approve student identity verification attempts
    'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': False,
    # Maximum number of rows to include in the csv file for downloading problem responses.
    'MAX_PROBLEM_RESPONSES_COUNT': 5000,

    'ENABLED_PAYMENT_REPORTS': [
        "refund_report",
        "itemized_purchase_report",
        "university_revenue_share",
        "certificate_status"
    ],

    # Turn off account locking if failed login attempts exceeds a limit
    'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True,

    # Hide any Personally Identifiable Information from application logs
    'SQUELCH_PII_IN_LOGS': True,
    # Toggles the embargo functionality, which blocks users from
    # the site or courses based on their location.
    'EMBARGO': False,

    # Whether the Wiki subsystem should be accessible via the direct /wiki/ paths. Setting this to True means
    # that people can submit content and modify the Wiki in any arbitrary manner. We're leaving this as True in the
    # defaults, so that we maintain current behavior
    'ALLOW_WIKI_ROOT_ACCESS': True,
    # .. toggle_name: ENABLE_THIRD_PARTY_AUTH
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Turn on third-party auth. Disabled for now because full mplementations are not yet
    #   available. Remember to run migrations if you enable this; we don't create tables by default. This feature can
    #   be enabled on a per-site basis. When enabling this feature, remember to define the allowed authentication
    #   backends with the AUTHENTICATION_BACKENDS setting.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-09-15
    # .. toggle_name: ENABLE_MKTG_SITE
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Toggle to enable alternate urls for marketing links.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2014-03-24
    # .. toggle_warnings: When this is enabled, the MKTG_URLS setting should be defined. The use case of this feature
    #   toggle is uncertain.
    'ENABLE_MKTG_SITE': False,

    # Prevent concurrent logins per user
    'PREVENT_CONCURRENT_LOGINS': True,
    # When a logged in user goes to the homepage ('/') should the user be
    # redirected to the dashboard - this is default Open edX behavior. Set to
    # False to not redirect the user
    'ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER': True,

    # .. toggle_name: ENABLE_COURSE_SORTING_BY_START_DATE
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: When a user goes to the homepage ('/') the user sees the courses listed in the
    #   announcement dates order - this is default Open edX behavior. Set to True to change the course sorting behavior
    #   by their start dates, latest first.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2015-03-27
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/7548
    'ENABLE_COURSE_SORTING_BY_START_DATE': True,
    # .. toggle_name: ENABLE_COURSE_HOME_REDIRECT
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: When enabled, along with the ENABLE_MKTG_SITE feature toggle, users who attempt to access a
    #   course "about" page will be redirected to the course home url. This url might be the course "info" page or the
    #   unified course tab (when the DISABLE_UNIFIED_COURSE_TAB_FLAG waffle is not enabled).
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2019-01-15
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/19604
    'ENABLE_COURSE_HOME_REDIRECT': True,

    # Expose Mobile REST API. Note that if you use this, you must also set
    # ENABLE_OAUTH2_PROVIDER to True
    'ENABLE_MOBILE_REST_API': False,

    # .. toggle_name: ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Display the standard footer in the login page. This feature can be overridden by a site-
    #   specific configuration.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2016-06-24
    # .. toggle_tickets: https://openedx.atlassian.net/browse/OSPR-1320
    'ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER': False,
    # Enable organizational email opt-in
    'ENABLE_MKTG_EMAIL_OPT_IN': False,

    # Show the mobile app links in the footer
    'ENABLE_FOOTER_MOBILE_APP_LINKS': False,
    # Let students save and manage their annotations
    'ENABLE_EDXNOTES': False,
    # Toggle to enable coordination with the Publisher tool (keep in sync with cms/envs/common.py)
    'ENABLE_PUBLISHER': False,

    # Milestones application flag
    'MILESTONES_APP': False,

    # Organizations application flag
    'ORGANIZATIONS_APP': False,

    # Prerequisite courses feature flag
    'ENABLE_PREREQUISITE_COURSES': False,

    # For easily adding modes to courses during acceptance testing
    'MODE_CREATION_FOR_TESTING': False,
    # For caching programs in contexts where the LMS can only
    # be reached over HTTP.
    'EXPOSE_CACHE_PROGRAMS_ENDPOINT': False,

    # Courseware search feature
    'ENABLE_COURSEWARE_SEARCH': False,
    'ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF': False,
Davorin Sego's avatar
Davorin Sego committed
    # Dashboard search feature
    'ENABLE_DASHBOARD_SEARCH': False,

    # log all information from cybersource callbacks
    'LOG_POSTPAY_CALLBACKS': True,
    # .. toggle_name: LICENSING
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Toggle platform-wide course licensing. The course.license attribute is then used to append
    #   license information to the courseware.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2015-05-14
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/7315
    # Certificates Web/HTML Views
    'CERTIFICATES_HTML_VIEW': False,
    # .. toggle_name: ENABLE_COURSE_DISCOVERY
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Add a course search widget to the LMS for searching courses. When this is enabled, the
    #   latest courses are no longer displayed on the LMS landing page. Also, an "Explore Courses" item is added to the
    #   navbar.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2015-04-23
    # .. toggle_warnings: The COURSE_DISCOVERY_MEANINGS setting should be properly defined.
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/7845
    # Setting for overriding default filtering facets for Course discovery
    # COURSE_DISCOVERY_FILTERS = ["org", "language", "modes"]

    # Software secure fake page feature flag
    'ENABLE_SOFTWARE_SECURE_FAKE': False,
    'ENABLE_TEAMS': True,
Alexander Kryklia's avatar
Alexander Kryklia committed

    # Show video bumper in LMS
    'ENABLE_VIDEO_BUMPER': False,

    # How many seconds to show the bumper again, default is 7 days:
    'SHOW_BUMPER_PERIODICITY': 7 * 24 * 3600,

    # .. toggle_name: ENABLE_SPECIAL_EXAMS
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Enable to use special exams, aka timed and proctored exams.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2015-09-04
    # .. toggle_tickets: https://github.com/edx/edx-platform/pull/9744
    'ENABLE_SPECIAL_EXAMS': False,
    # Enable OpenBadge support. See the BADGR_* settings later in this file.
    'ENABLE_OPENBADGES': False,
    # Enable LTI Provider feature.
    'ENABLE_LTI_PROVIDER': False,
    # Show the language selector in the header
    'SHOW_HEADER_LANGUAGE_SELECTOR': False,

    # At edX it's safe to assume that English transcripts are always available
    # This is not the case for all installations.
    # The default value in {lms,cms}/envs/common.py and xmodule/tests/test_video.py should be consistent.
    'FALLBACK_TO_ENGLISH_TRANSCRIPTS': True,

    # Show the language selector in the footer
    'SHOW_FOOTER_LANGUAGE_SELECTOR': False,
    # .. toggle_name: ENABLE_CSMH_EXTENDED
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: Write Courseware Student Module History (CSMH) to the extended table: this logs all
    #   student activities to MySQL, in a separate database.
    # .. toggle_use_cases: open_edx
    # .. toggle_warnings: Even though most Open edX instances run with a separate CSMH database, it may not always be
    #   the case. When disabling this feature flag, remember to remove "coursewarehistoryextended" from the
    #   INSTALLED_APPS and the "StudentModuleHistoryExtendedRouter" from the DATABASE_ROUTERS.
    'ENABLE_CSMH_EXTENDED': True,

    # Read from both the CSMH and CSMHE history tables.
    # This is the default, but can be disabled if all history
    # lives in the Extended table, saving the frontend from
    # making multiple queries.
    'ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES': True,
    # Set this to False to facilitate cleaning up invalid xml from your modulestore.
    'ENABLE_XBLOCK_XML_VALIDATION': True,
    # .. toggle_name: ALLOW_PUBLIC_ACCOUNT_CREATION
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: True
    # .. toggle_description: Allow public account creation. If this is disabled, users will no longer have access to
    #   the signup page.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2017-04-12
    # .. toggle_tickets: https://openedx.atlassian.net/browse/YONK-513
    'ALLOW_PUBLIC_ACCOUNT_CREATION': True,

    # Enable footer banner for cookie consent.
    # See https://cookieconsent.insites.com/ for more.
    'ENABLE_COOKIE_CONSENT': False,

    # Whether or not the dynamic EnrollmentTrackUserPartition should be registered.
    'ENABLE_ENROLLMENT_TRACK_USER_PARTITION': True,

    # Enable one click program purchase
    # See LEARNER-493
    'ENABLE_ONE_CLICK_PROGRAM_PURCHASE': False,
    # Allow users to change their email address.
    'ALLOW_EMAIL_ADDRESS_CHANGE': True,
    # Whether the bulk enrollment view is enabled.
    'ENABLE_BULK_ENROLLMENT_VIEW': False,

    # Whether course goals is enabled.
    'ENABLE_COURSE_GOALS': True,

    # Set to enable Enterprise integration
    'ENABLE_ENTERPRISE_INTEGRATION': False,

    # Whether HTML XBlocks/XModules return HTML content with the Course Blocks API student_view_data
    'ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA': False,
    # .. toggle_name: ENABLE_CHANGE_USER_PASSWORD_ADMIN
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Whether to send an email for failed password reset attempts or not. This happens when a
    #   user asks for a password reset but they don't have an account associated to their email. This is useful for
    #   notifying users that they don't have an account associated with email addresses they believe they've registered
    #   with. This setting can be overridden by a site-specific configuration.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2017-07-20
    # .. toggle_tickets: https://openedx.atlassian.net/browse/OSPR-1832
    'ENABLE_PASSWORD_RESET_FAILURE_EMAIL': False,
    # Sets the default browser support. For more information go to http://browser-update.org/customize.html
    'UNSUPPORTED_BROWSER_ALERT_VERSIONS': "{i:10,f:-3,o:-3,s:-3,c:-3}",

    # Whether to display the account deletion section the account settings page
    'ENABLE_ACCOUNT_DELETION': True,

    # Enable feature to remove enrollments and users. Used to reset state of master's integration environments
    'ENABLE_ENROLLMENT_RESET': False,
    'DISABLE_MOBILE_COURSE_AVAILABLE': False,

    # .. toggle_name: ENABLE_CHANGE_USER_PASSWORD_ADMIN
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set to True to enable changing a user password through django admin. This is disabled by
    #   default because enabling allows a method to bypass password policy.
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2020-02-21
    # .. toggle_tickets: 'https://github.com/edx/edx-platform/pull/21616'
    'ENABLE_CHANGE_USER_PASSWORD_ADMIN': False,

    # .. toggle_name: ENABLE_COURSEWARE_MICROFRONTEND
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set to True to enable the Courseware MFE at the platform level for global staff (see
    #   REDIRECT_TO_COURSEWARE_MICROFRONTEND for course rollout)
    # .. toggle_use_cases: open_edx
    # .. toggle_creation_date: 2020-03-05
    # .. toggle_tickets: 'https://github.com/edx/edx-platform/pull/23317'
    # .. toggle_warnings: Also set settings.LEARNING_MICROFRONTEND_URL and see REDIRECT_TO_COURSEWARE_MICROFRONTEND for
    #   rollout.
    'ENABLE_COURSEWARE_MICROFRONTEND': False,
    # .. toggle_name: ENABLE_LOGISTRATION_MICROFRONTEND
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the logistration.
    # .. toggle_use_cases: temporary, open_edx
    # .. toggle_creation_date: 2020-09-08
    # .. toggle_target_removal_date: None
    # .. toggle_tickets: 'https://github.com/edx/edx-platform/pull/24908'
    # .. toggle_warnings: Also set settings.LOGISTRATION_MICROFRONTEND_URL for rollout. This temporary feature
    # toggle does not have a target removal date.
    'ENABLE_LOGISTRATION_MICROFRONTEND': False,

    ### ORA Feature Flags ###
    # .. toggle_name: ENABLE_ORA_ALL_FILE_URLS
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: A "work-around" feature toggle meant to help in cases where some file uploads are not
    #   discoverable.  If enabled, will iterate through all possible file key suffixes up to the max for displaying
    #  file metadata in staff assessments.
    # .. toggle_use_cases: temporary
    # .. toggle_creation_date: 2020-03-03
    # .. toggle_target_removal_date: None
    # .. toggle_tickets: https://openedx.atlassian.net/browse/EDUCATOR-4951
    # .. toggle_warnings: This temporary feature toggle does not have a target removal date.
    'ENABLE_ORA_ALL_FILE_URLS': False,

    # .. toggle_name: ENABLE_ORA_USER_STATE_UPLOAD_DATA
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: A "work-around" feature toggle meant to help in cases where some file uploads are not
    #   discoverable.  If enabled, will pull file metadata from StudentModule.state for display in staff assessments.
    # .. toggle_use_cases: temporary
    # .. toggle_creation_date: 2020-03-03
    # .. toggle_target_removal_date: None
    # .. toggle_tickets: https://openedx.atlassian.net/browse/EDUCATOR-4951
    # .. toggle_warnings: This temporary feature toggle does not have a target removal date.
    'ENABLE_ORA_USER_STATE_UPLOAD_DATA': False,

    # .. toggle_name: ENABLE_ORA_USERNAMES_ON_DATA_EXPORT
    # .. toggle_implementation: DjangoSetting
    # .. toggle_default: False
    # .. toggle_description: Set to True to add deanonymized usernames to ORA data
    #   report.
    # .. toggle_use_cases: temporary
    # .. toggle_creation_date: 2020-06-11
    # .. toggle_target_removal_date: None
    # .. toggle_tickets: https://openedx.atlassian.net/browse/TNL-7273
    # .. toggle_warnings: This temporary feature toggle does not have a target removal date.
    'ENABLE_ORA_USERNAMES_ON_DATA_EXPORT': False,
# Specifies extra XBlock fields that should available when requested via the Course Blocks API
# Should be a list of tuples of (block_type, field_name), where block_type can also be "*" for all block types.
# e.g. COURSE_BLOCKS_API_EXTRA_FIELDS = [  ('course', 'other_course_settings'), ("problem", "weight")  ]
COURSE_BLOCKS_API_EXTRA_FIELDS = []

# Settings for the course reviews tool template and identification key, set either to None to disable course reviews
COURSE_REVIEWS_TOOL_PROVIDER_FRAGMENT_NAME = 'coursetalk-reviews-fragment.html'
COURSE_REVIEWS_TOOL_PROVIDER_PLATFORM_KEY = 'edx'

# CDN links to CourseTalk scripts to load read and write widgets
COURSE_TALK_READ_ONLY_SOURCE = '//d3q6qq2zt8nhwv.cloudfront.net/s/js/widgets/coursetalk-read-reviews.js'
COURSE_TALK_WRITE_ONLY_SOURCE = '//d3q6qq2zt8nhwv.cloudfront.net/s/js/widgets/coursetalk-write-reviews.js'

# Ignore static asset files on import which match this pattern
ASSET_IGNORE_REGEX = r"(^\._.*$)|(^\.DS_Store$)|(^.*~$)"

# 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

XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5  # seconds
nadeemshahzad's avatar
nadeemshahzad committed
XQUEUE_INTERFACE = {
    'url': 'http://localhost:18040',
    'basic_auth': ['edx', 'edx'],
    'django_auth': {
        'username': 'lms',
        'password': 'password'
    }
}
# Used with Email sending
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS = 5
RETRY_ACTIVATION_EMAIL_TIMEOUT = 0.5

# Software Secure request retry settings
# Time in seconds before a retry of the task should be 60 mints.
SOFTWARE_SECURE_REQUEST_RETRY_DELAY = 60 * 60
# Maximum of 6 retries before giving up.
SOFTWARE_SECURE_RETRY_MAX_ATTEMPTS = 6

RETRY_CALENDAR_SYNC_EMAIL_MAX_ATTEMPTS = 5
# Deadline message configurations
COURSE_MESSAGE_ALERT_DURATION_IN_DAYS = 14

############################# SET PATH INFORMATION #############################
PROJECT_ROOT = path(__file__).abspath().dirname().dirname()  # /edx-platform/lms
REPO_ROOT = PROJECT_ROOT.dirname()
COMMON_ROOT = REPO_ROOT / "common"
OPENEDX_ROOT = REPO_ROOT / "openedx"
ENV_ROOT = REPO_ROOT.dirname()  # virtualenv dir /edx-platform is in
COURSES_ROOT = ENV_ROOT / "data"
NODE_MODULES_ROOT = REPO_ROOT / "node_modules"

DATA_DIR = COURSES_ROOT

# TODO: Is this next line necessary?
# TODO: The next two path modifications will be removed in an upcoming Open edX release.
# See docs/decisions/0007-sys-path-modification-removal.rst
sys.path.append(REPO_ROOT / 'sys_path_hacks' / 'lms')
sys.path.append(COMMON_ROOT / 'djangoapps')
system_node_path = os.environ.get("NODE_PATH", NODE_MODULES_ROOT)
node_paths = [
    COMMON_ROOT / "static/js/vendor",
    system_node_path,
]
# For geolocation ip database
adeelehsan's avatar
adeelehsan committed
GEOIP_PATH = REPO_ROOT / "common/static/data/geoip/GeoLite2-Country.mmdb"
# Where to look for a status message
STATUS_MESSAGE_PATH = ENV_ROOT / "status_message.json"
############################ Global Database Configuration #####################

DATABASE_ROUTERS = [
    'openedx.core.lib.django_courseware_routers.StudentModuleHistoryExtendedRouter',
    'edx_django_utils.db.read_replica.ReadReplicaRouter',
nadeemshahzad's avatar
nadeemshahzad committed
############################ Cache Configuration ###############################

CACHES = {
    'blockstore': {
        'KEY_PREFIX': 'blockstore',
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'TIMEOUT': '86400',  # This data should be long-lived for performance, BundleCache handles invalidation
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
nadeemshahzad's avatar
nadeemshahzad committed
    'course_structure_cache': {
        'KEY_PREFIX': 'course_structure',
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'TIMEOUT': '7200',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'celery': {
        'KEY_PREFIX': 'celery',
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'TIMEOUT': '7200',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'mongo_metadata_inheritance': {
        'KEY_PREFIX': 'mongo_metadata_inheritance',
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'TIMEOUT': 300,
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'staticfiles': {
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'KEY_PREFIX': 'staticfiles_general',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'default': {
        'VERSION': '1',
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'KEY_PREFIX': 'default',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'configuration': {
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'KEY_PREFIX': 'configuration',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
    'general': {
        'KEY_FUNCTION': 'util.memcache.safe_key',
        'LOCATION': ['localhost:11211'],
        'KEY_PREFIX': 'general',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    },
}

############################ OAUTH2 Provider ###################################
OAUTH_EXPIRE_CONFIDENTIAL_CLIENT_DAYS = 365
OAUTH_EXPIRE_PUBLIC_CLIENT_DAYS = 30
################################## DJANGO OAUTH TOOLKIT #######################################

# Scope description strings are presented to the user
# on the application authorization page. See
# lms/templates/oauth2_provider/authorize.html for details.
# Non-default scopes should be added directly to OAUTH2_PROVIDER['SCOPES'] below.
OAUTH2_DEFAULT_SCOPES = {
    'read': _('Read access'),
    'write': _('Write access'),
    'email': _('Know your email address'),
    'profile': _('Know your name and username'),
}

    'OAUTH2_VALIDATOR_CLASS': 'openedx.core.djangoapps.oauth_dispatch.dot_overrides.validators.EdxOAuth2Validator',
    # 3 months and then we expire refresh tokens using edx_clear_expired_tokens (length is mobile app driven)
    'REFRESH_TOKEN_EXPIRE_SECONDS': 7776000,
    'SCOPES_BACKEND_CLASS': 'openedx.core.djangoapps.oauth_dispatch.scopes.ApplicationModelScopes',
    'SCOPES': dict(OAUTH2_DEFAULT_SCOPES, **{
        'certificates:read': _('Retrieve your course certificates'),
        'grades:read': _('Retrieve your grades for your enrolled courses'),
        'tpa:read': _('Retrieve your third-party authentication username mapping'),
        'user_id': _('Know your user identifier'),
    }),
    'DEFAULT_SCOPES': OAUTH2_DEFAULT_SCOPES,
    'REQUEST_APPROVAL_PROMPT': 'auto_even_if_expired',
    'ERROR_RESPONSE_WITH_SCOPES': True,
# This is required for the migrations in oauth_dispatch.models
# otherwise it fails saying this attribute is not present in Settings
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
# Automatically clean up edx-django-oauth2-provider tokens on use
OAUTH_DELETE_EXPIRED = True
OAUTH_ID_TOKEN_EXPIRATION = 60 * 60
nadeemshahzad's avatar
nadeemshahzad committed
OAUTH_ENFORCE_SECURE = True
OAUTH_EXPIRE_CONFIDENTIAL_CLIENT_DAYS = 365
OAUTH_EXPIRE_PUBLIC_CLIENT_DAYS = 30
################################## THIRD_PARTY_AUTH CONFIGURATION #############################
TPA_PROVIDER_BURST_THROTTLE = '10/min'
TPA_PROVIDER_SUSTAINED_THROTTLE = '50/hr'

################################## TEMPLATE CONFIGURATION #####################################
# Mako templating
nadeemshahzad's avatar
nadeemshahzad committed
import tempfile  # pylint: disable=wrong-import-order
MAKO_MODULE_DIR = os.path.join(tempfile.gettempdir(), 'mako_lms')
MAKO_TEMPLATE_DIRS_BASE = [
    PROJECT_ROOT / 'templates',
    COMMON_ROOT / 'templates',
    COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
    COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
    OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
    OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
    OPENEDX_ROOT / 'core' / 'lib' / 'license' / 'templates',
    OPENEDX_ROOT / 'features' / 'course_experience' / 'templates',
Piotr Mitros's avatar
Piotr Mitros committed

def _make_mako_template_dirs(settings):
    Derives the final Mako template directories list from other settings.
    """
    if settings.ENABLE_COMPREHENSIVE_THEMING:
        themes_dirs = get_theme_base_dirs_from_settings(settings.COMPREHENSIVE_THEME_DIRS)
        for theme in get_themes_unchecked(themes_dirs, settings.PROJECT_ROOT):
            if theme.themes_base_dir not in settings.MAKO_TEMPLATE_DIRS_BASE:
                settings.MAKO_TEMPLATE_DIRS_BASE.insert(0, theme.themes_base_dir)
    return settings.MAKO_TEMPLATE_DIRS_BASE


CONTEXT_PROCESSORS = [
    'django.template.context_processors.request',
    'django.template.context_processors.static',
    'django.template.context_processors.i18n',
    'django.contrib.auth.context_processors.auth',  # this is required for admin
    'django.template.context_processors.csrf',

    # Added for django-wiki
    'django.template.context_processors.media',
    'django.template.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'sekizai.context_processors.sekizai',

    # Hack to get required link URLs to password reset templates
    'edxmako.shortcuts.marketing_link_context_processor',

    # Timezone processor (sends language and time_zone preference)
    'lms.djangoapps.courseware.context_processor.user_timezone_locale_prefs',

    # Online contextual help
    'help_tokens.context_processor',
    'openedx.core.djangoapps.site_configuration.context_processors.configuration_context',

    # Mobile App processor (Detects if request is from the mobile app)
    'mobile_api.context_processor.is_from_mobile_app'
# Django templating
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        # Don't look for template source files inside installed applications.
        'APP_DIRS': False,
        # Instead, look for template source files in these dirs.
        'DIRS': [
            PROJECT_ROOT / "templates",
            COMMON_ROOT / 'templates',
            COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
            COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
            COMMON_ROOT / 'static',  # required to statically include common Underscore templates
        ],
        # Options specific to this backend.
        'OPTIONS': {
            'loaders': [
                # We have to use mako-aware template loaders to be able to include
                # mako templates inside django templates (such as main_django.html).
                'openedx.core.djangoapps.theming.template_loaders.ThemeTemplateLoader',
                'edxmako.makoloader.MakoFilesystemLoader',
                'edxmako.makoloader.MakoAppDirectoriesLoader',
            ],
            'context_processors': CONTEXT_PROCESSORS,
            # Change 'debug' in your environment settings files - not here.
            'debug': False
        }
    },
    {
        'NAME': 'mako',
        'BACKEND': 'edxmako.backend.Mako',
        # Don't look for template source files inside installed applications.
        'APP_DIRS': False,
        # Instead, look for template source files in these dirs.
        'DIRS': _make_mako_template_dirs,
        # Options specific to this backend.
        'OPTIONS': {
            'context_processors': CONTEXT_PROCESSORS,
            # Change 'debug' in your environment settings files - not here.
            'debug': False,
        }
    },
derived_collection_entry('TEMPLATES', 1, 'DIRS')
DEFAULT_TEMPLATE_ENGINE = TEMPLATES[0]
DEFAULT_TEMPLATE_ENGINE_DIRS = DEFAULT_TEMPLATE_ENGINE['DIRS'][:]

###############################################################################################
AUTHENTICATION_BACKENDS = [
    'rules.permissions.ObjectPermissionBackend',
    'openedx.core.djangoapps.oauth_dispatch.dot_overrides.backends.EdxRateLimitedAllowAllUsersModelBackend',
    'bridgekeeper.backends.RulePermissionBackend',
STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000  # 4 MB
# Set request limits for maximum size of a request body and maximum number of GET/POST parameters. (>=Django 1.10)
# Limits are currently disabled - but can be used for finer-grained denial-of-service protection.
DATA_UPLOAD_MAX_MEMORY_SIZE = None
DATA_UPLOAD_MAX_NUMBER_FIELDS = None

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

nadeemshahzad's avatar
nadeemshahzad committed
# License for serving content in China
ICP_LICENSE = None
ICP_LICENSE_INFO = {}

ELASTIC_SEARCH_CONFIG = [
    {
        'use_ssl': False,
        'host': 'localhost',
        'port': 9200
    }
]

VIDEO_CDN_URL = {
    'EXAMPLE_COUNTRY_CODE': "http://example.com/edx/video?s3_url="
}

STATIC_ROOT_BASE = '/edx/var/edxapp/staticfiles'

LOGGING_ENV = 'sandbox'

EDX_ROOT_URL = ''
EDX_API_KEY = "PUT_YOUR_API_KEY_HERE"
LOGIN_REDIRECT_URL = EDX_ROOT_URL + '/login'
LOGIN_URL = EDX_ROOT_URL + '/login'
nadeemshahzad's avatar
nadeemshahzad committed
PARTNER_SUPPORT_EMAIL = ''

CERT_QUEUE = 'certificates'

ALTERNATE_WORKER_QUEUES = 'cms'

LOCAL_LOGLEVEL = "INFO"

LOG_DIR = '/edx/var/log/edx'

DATA_DIR = '/edx/var/edxapp/data'
nadeemshahzad's avatar
nadeemshahzad committed

MAINTENANCE_BANNER_TEXT = 'Sample banner message'

GIT_REPO_DIR = '/edx/var/edxapp/course_repos'

DJFS = {
    'type': 'osfs',
    'directory_root': '/edx/var/edxapp/django-pyfs/static/django-pyfs',
nadeemshahzad's avatar
nadeemshahzad committed
    'url_root': '/static/django-pyfs',
}

### Dark code. Should be enabled in local settings for devel.
ENABLE_MULTICOURSE = False  # set to False to disable multicourse display (see lib.util.views.edXhome)
nadeemshahzad's avatar
nadeemshahzad committed
WIKI_ENABLED = True
COURSE_MODE_DEFAULTS = {
    'bulk_sku': None,
Ayub khan's avatar
Ayub khan committed
    'currency': u'usd',
    'description': None,
    'expiration_datetime': None,
    'min_price': 0,
Ayub khan's avatar
Ayub khan committed
    'name': _(u'Audit'),
Ayub khan's avatar
Ayub khan committed
    'slug': u'audit',
Victor Shnayder's avatar
Victor Shnayder committed
# 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 = []
USAGE_KEY_PATTERN = r'(?P<usage_key_string>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'
ASSET_KEY_PATTERN = r'(?P<asset_key_string>(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'
USAGE_ID_PATTERN = r'(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'


# The space is required for space-dependent languages like Arabic and Farsi.
# However, backward compatibility with Ficus older releases is still maintained (space is still not valid)
# in the AccountCreationForm and the user_api through the ENABLE_UNICODE_USERNAME feature flag.
USERNAME_REGEX_PARTIAL = r'[\w .@_+-]+'
USERNAME_PATTERN = r'(?P<username>{regex})'.format(regex=USERNAME_REGEX_PARTIAL)


############################## EVENT TRACKING #################################

# FIXME: Should we be doing this truncation?
TRACK_MAX_EVENT = 50000

DEBUG_TRACK_LOG = False

TRACKING_BACKENDS = {
    'logger': {
        'ENGINE': 'track.backends.logger.LoggerBackend',
        'OPTIONS': {
            'name': 'tracking'
        }
    }
}

# We're already logging events, and we don't want to capture user
# names/passwords.  Heartbeat events are likely not interesting.
TRACKING_IGNORE_URL_PATTERNS = [r'^/event', r'^/login', r'^/heartbeat', r'^/segmentio/event', r'^/performance']

EVENT_TRACKING_ENABLED = True
EVENT_TRACKING_BACKENDS = {
    'tracking_logs': {
        'ENGINE': 'eventtracking.backends.routing.RoutingBackend',
        'OPTIONS': {
            'backends': {
                'logger': {
                    'ENGINE': 'eventtracking.backends.logger.LoggerBackend',
                    'OPTIONS': {
                        'name': 'tracking',
                        'max_event_size': TRACK_MAX_EVENT,
                    }
                }
            },
            'processors': [
                {'ENGINE': 'track.shim.LegacyFieldMappingProcessor'},
                {'ENGINE': 'track.shim.PrefixedEventProcessor'}
    'segmentio': {
        'ENGINE': 'eventtracking.backends.routing.RoutingBackend',
        'OPTIONS': {
            'backends': {
                'segment': {'ENGINE': 'eventtracking.backends.segment.SegmentBackend'}
            },
            'processors': [
                {
                    'ENGINE': 'eventtracking.processors.whitelist.NameWhitelistProcessor',
                    'OPTIONS': {
                        'whitelist': []
                    }
                },
                {
                    'ENGINE': 'track.shim.GoogleAnalyticsProcessor'
}
EVENT_TRACKING_PROCESSORS = []
nadeemshahzad's avatar
nadeemshahzad committed
EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST = []
TRACKING_SEGMENTIO_WEBHOOK_SECRET = None
TRACKING_SEGMENTIO_ALLOWED_TYPES = ['track']
TRACKING_SEGMENTIO_DISALLOWED_SUBSTRING_NAMES = []
TRACKING_SEGMENTIO_SOURCE_MAP = {
    'analytics-android': 'mobile',
    'analytics-ios': 'mobile',
}
######################## GOOGLE ANALYTICS ###########################
GOOGLE_ANALYTICS_ACCOUNT = None
nadeemshahzad's avatar
nadeemshahzad committed
GOOGLE_SITE_VERIFICATION_ID = ''
GOOGLE_ANALYTICS_LINKEDIN = 'GOOGLE_ANALYTICS_LINKEDIN_DUMMY'
GOOGLE_ANALYTICS_TRACKING_ID = None
######################## BRANCH.IO ###########################
nadeemshahzad's avatar
nadeemshahzad committed
BRANCH_IO_KEY = ''
######################## OPTIMIZELY ###########################
OPTIMIZELY_PROJECT_ID = None

######################## subdomain specific settings ###########################
COURSE_LISTINGS = {}

Calen Pennington's avatar
Calen Pennington committed
############# XBlock Configuration ##########

# Import after sys.path fixup
# pylint: disable=wrong-import-position
from xmodule.modulestore.edit_info import EditInfoMixin
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.modulestore import prefer_xmodules
from xmodule.x_module import XModuleMixin
# pylint: enable=wrong-import-position
# These are the Mixins that should be added to every XBlock.
Calen Pennington's avatar
Calen Pennington committed
# 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, XModuleMixin, EditInfoMixin)
Calen Pennington's avatar
Calen Pennington committed

# Allow any XBlock in the LMS
XBLOCK_SELECT_FUNCTION = prefer_xmodules
# Paths to wrapper methods which should be applied to every XBlock's FieldData.
XBLOCK_FIELD_DATA_WRAPPERS = ()

nadeemshahzad's avatar
nadeemshahzad committed
XBLOCK_FS_STORAGE_BUCKET = None
XBLOCK_FS_STORAGE_PREFIX = None
XBLOCK_SETTINGS = {}

############# ModuleStore Configuration ##########

Nimisha Asthagiri's avatar
Nimisha Asthagiri committed
MODULESTORE_BRANCH = 'published-only'
DOC_STORE_CONFIG = {
    'db': 'edxapp',
    'host': 'localhost',
    'replicaSet': '',
    'password': 'password',
    'port': 27017,
    'user': 'edxapp',
    'collection': 'modulestore',
    'ssl': False,
    # https://api.mongodb.com/python/2.9.1/api/pymongo/mongo_client.html#module-pymongo.mongo_client
    # default is never timeout while the connection is open,
    #this means it needs to explicitly close raising pymongo.errors.NetworkTimeout
    'socketTimeoutMS': 6000,
    'connectTimeoutMS': 2000,  # default is 20000, I believe raises pymongo.errors.ConnectionFailure
    # Not setting waitQueueTimeoutMS and waitQueueMultiple since pymongo defaults to nobody being allowed to wait
    'auth_source': None,
    'read_preference': 'SECONDARY_PREFERRED'
nadeemshahzad's avatar
nadeemshahzad committed

CONTENTSTORE = {
    'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
    # connection strings are duplicated temporarily for
    # backward compatibility
    'OPTIONS': {
        'db': 'edxapp',
        'host': 'localhost',
        'password': 'password',
nadeemshahzad's avatar
nadeemshahzad committed
        'port': 27017,
        'user': 'edxapp',
        'ssl': False,
        'auth_source': None
nadeemshahzad's avatar
nadeemshahzad committed
    },
    'ADDITIONAL_OPTIONS': {},
    'DOC_STORE_CONFIG': DOC_STORE_CONFIG
}

MODULESTORE = {
    'default': {
        'ENGINE': 'xmodule.modulestore.mixed.MixedModuleStore',
        'OPTIONS': {
            'mappings': {},
            'stores': [
                {
cahrens's avatar
cahrens committed
                    'NAME': 'split',
                    'ENGINE': 'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore',
                    'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
                    'OPTIONS': {
                        'default_class': 'xmodule.hidden_module.HiddenDescriptor',
                        'fs_root': DATA_DIR,
                        'render_template': 'edxmako.shortcuts.render_to_string',
                    }
                },
                {
cahrens's avatar
cahrens committed
                    'NAME': 'draft',
                    'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore',
                    'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
                    'OPTIONS': {
                        'default_class': 'xmodule.hidden_module.HiddenDescriptor',
cahrens's avatar
cahrens committed
                        'fs_root': DATA_DIR,
                        'render_template': 'edxmako.shortcuts.render_to_string',
nadeemshahzad's avatar
nadeemshahzad committed
DATABASES = {
    # edxapp's edxapp-migrate scripts and the edxapp_migrate play
    # will ensure that any DB not named read_replica will be migrated
    # for both the lms and cms.
    'default': {
        'ATOMIC_REQUESTS': True,
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.mysql',
        'HOST': 'localhost',
        'NAME': 'edxapp',
        'OPTIONS': {},
        'PASSWORD': 'password',
        'PORT': '3306',
        'USER': 'edxapp001'
    },
    'read_replica': {
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.mysql',
        'HOST': 'localhost',
        'NAME': 'edxapp',
nadeemshahzad's avatar
nadeemshahzad committed
        'OPTIONS': {},
        'PASSWORD': 'password',
        'PORT': '3306',
        'USER': 'edxapp001'
    },
    'student_module_history': {
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.mysql',
        'HOST': 'localhost',
        'NAME': 'edxapp_csmh',
        'OPTIONS': {},
        'PASSWORD': 'password',
        'PORT': '3306',
        'USER': 'edxapp001'
#################### Python sandbox ############################################

CODE_JAIL = {
nadeemshahzad's avatar
nadeemshahzad committed
    # from https://github.com/edx/codejail/blob/master/codejail/django_integration.py#L24, '' should be same as None
    'python_bin': '/edx/app/edxapp/venvs/edxapp-sandbox/bin/python',
    # User to run as in the sandbox.
    'user': 'sandbox',

    # Configurable limits.
    'limits': {
        # How many CPU seconds can jailed code use?
        'CPU': 1,
nadeemshahzad's avatar
nadeemshahzad committed
        # Limit the memory of the jailed process to something high but not
        # infinite (512MiB in bytes)
        'VMEM': 536870912,
        # Time in seconds that the jailed process has to run.
        'REALTIME': 3,
        'PROXY': 0,
# 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 = []
############################### DJANGO BUILT-INS ###############################
# Change DEBUG in your environment settings files, not here
DEBUG = False
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = 'openedx.core.lib.session_serializers.PickleSerializer'
nadeemshahzad's avatar
nadeemshahzad committed
SESSION_COOKIE_DOMAIN = ""
SESSION_COOKIE_NAME = 'sessionid'
# django-session-cookie middleware
DCS_SESSION_COOKIE_SAMESITE = 'None'
DCS_SESSION_COOKIE_SAMESITE_FORCE_ALL = True
nadeemshahzad's avatar
nadeemshahzad committed
CMS_BASE = 'localhost:18010'

# LMS base
LMS_BASE = 'localhost:18000'

# Studio name
STUDIO_NAME = 'Studio'
STUDIO_SHORT_NAME = 'Studio'
# Site info
nadeemshahzad's avatar
nadeemshahzad committed
SITE_NAME = "localhost"
HTTPS = 'on'
ROOT_URLCONF = 'lms.urls'
# NOTE: Please set ALLOWED_HOSTS to some sane value, as we do not allow the default '*'
# Platform Email
nadeemshahzad's avatar
nadeemshahzad committed
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_USE_TLS = False
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = 'registration@example.com'
DEFAULT_FEEDBACK_EMAIL = 'feedback@example.com'
SERVER_EMAIL = 'devops@example.com'
TECH_SUPPORT_EMAIL = 'technical@example.com'
CONTACT_EMAIL = 'info@example.com'
BUGS_EMAIL = 'bugs@example.com'
UNIVERSITY_EMAIL = 'university@example.com'
PRESS_EMAIL = 'press@example.com'

# Platform mailing address
nadeemshahzad's avatar
nadeemshahzad committed
CONTACT_MAILING_ADDRESS = 'SET-ME-PLEASE'
# Account activation email sender address
ACTIVATION_EMAIL_FROM_ADDRESS = ''

# Static content
STATIC_URL = '/static/'
STATIC_ROOT = ENV_ROOT / "staticfiles"
nadeemshahzad's avatar
nadeemshahzad committed
STATIC_URL_BASE = '/static/'
jaebradley's avatar
jaebradley committed
    NODE_MODULES_ROOT / "@edx",
FAVICON_PATH = 'images/favicon.ico'
DEFAULT_COURSE_ABOUT_IMAGE_URL = 'images/pencils.jpg'
nadeemshahzad's avatar
nadeemshahzad committed
CAS_SERVER_URL = ""
CAS_EXTRA_LOGIN_PARAMS = ""
CAS_ATTRIBUTE_CALLBACK = ""

# User-uploaded content
MEDIA_ROOT = '/edx/var/edxapp/media/'
MEDIA_URL = '/media/'

# Locale/Internationalization
CELERY_TIMEZONE = 'UTC'
TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en'  # http://www.i18nguy.com/unicode/language-identifiers.html
# these languages display right to left
LANGUAGES_BIDI = ("he", "ar", "fa", "ur", "fa-ir", "rtl")
LANGUAGE_COOKIE = "openedx-language-preference"

# Sourced from http://www.localeplanet.com/icu/ and wikipedia
    ('en', u'English'),
    ('rtl', u'Right-to-Left Test Language'),
    ('eo', u'Dummy Language (Esperanto)'),  # Dummy languaged used for testing
    ('fake2', u'Fake translations'),        # Another dummy language for testing (not pushed to prod)
Sarina Canelake's avatar
Sarina Canelake committed
    ('am', u'አማርኛ'),  # Amharic
    ('ar', u'العربية'),  # Arabic
    ('az', u'azərbaycanca'),  # Azerbaijani
    ('bg-bg', u'български (България)'),  # Bulgarian (Bulgaria)
    ('bn-bd', u'বাংলা (বাংলাদেশ)'),  # Bengali (Bangladesh)
Sarina Canelake's avatar
Sarina Canelake committed
    ('bn-in', u'বাংলা (ভারত)'),  # Bengali (India)
    ('bs', u'bosanski'),  # Bosnian
    ('ca', u'Català'),  # Catalan
    ('ca@valencia', u'Català (València)'),  # Catalan (Valencia)
    ('cs', u'Čeština'),  # Czech
    ('cy', u'Cymraeg'),  # Welsh
Sarina Canelake's avatar
Sarina Canelake committed
    ('da', u'dansk'),  # Danish
    ('de-de', u'Deutsch (Deutschland)'),  # German (Germany)
    ('el', u'Ελληνικά'),  # Greek
    ('en-uk', u'English (United Kingdom)'),  # English (United Kingdom)
    ('en@lolcat', u'LOLCAT English'),  # LOLCAT English
    ('en@pirate', u'Pirate English'),  # Pirate English
    ('es-419', u'Español (Latinoamérica)'),  # Spanish (Latin America)
    ('es-ar', u'Español (Argentina)'),  # Spanish (Argentina)
    ('es-ec', u'Español (Ecuador)'),  # Spanish (Ecuador)
    ('es-es', u'Español (España)'),  # Spanish (Spain)
    ('es-mx', u'Español (México)'),  # Spanish (Mexico)
    ('es-pe', u'Español (Perú)'),  # Spanish (Peru)
    ('et-ee', u'Eesti (Eesti)'),  # Estonian (Estonia)
    ('eu-es', u'euskara (Espainia)'),  # Basque (Spain)
    ('fa', u'فارسی'),  # Persian
    ('fa-ir', u'فارسی (ایران)'),  # Persian (Iran)
    ('fi-fi', u'Suomi (Suomi)'),  # Finnish (Finland)
    ('fil', u'Filipino'),  # Filipino
    ('fr', u'Français'),  # French
    ('gl', u'Galego'),  # Galician
Sarina Canelake's avatar
Sarina Canelake committed
    ('gu', u'ગુજરાતી'),  # Gujarati
    ('he', u'עברית'),  # Hebrew
    ('hi', u'हिन्दी'),  # Hindi
Sarina Canelake's avatar
Sarina Canelake committed
    ('hr', u'hrvatski'),  # Croatian
    ('hu', u'magyar'),  # Hungarian
    ('hy-am', u'Հայերեն (Հայաստան)'),  # Armenian (Armenia)
    ('id', u'Bahasa Indonesia'),  # Indonesian
    ('it-it', u'Italiano (Italia)'),  # Italian (Italy)
Sarina Canelake's avatar
Sarina Canelake committed
    ('ja-jp', u'日本語 (日本)'),  # Japanese (Japan)
    ('kk-kz', u'қазақ тілі (Қазақстан)'),  # Kazakh (Kazakhstan)
    ('km-kh', u'ភាសាខ្មែរ (កម្ពុជា)'),  # Khmer (Cambodia)
Sarina Canelake's avatar
Sarina Canelake committed
    ('kn', u'ಕನ್ನಡ'),  # Kannada
Sarina Canelake's avatar
Sarina Canelake committed
    ('ko-kr', u'한국어 (대한민국)'),  # Korean (Korea)
    ('lt-lt', u'Lietuvių (Lietuva)'),  # Lithuanian (Lithuania)
    ('ml', u'മലയാളം'),  # Malayalam
    ('mn', u'Монгол хэл'),  # Mongolian
    ('mr', u'मराठी'),  # Marathi
    ('ms', u'Bahasa Melayu'),  # Malay
    ('nb', u'Norsk bokmål'),  # Norwegian Bokmål
    ('ne', u'नेपाली'),  # Nepali
    ('nl-nl', u'Nederlands (Nederland)'),  # Dutch (Netherlands)
Sarina Canelake's avatar
Sarina Canelake committed
    ('or', u'ଓଡ଼ିଆ'),  # Oriya
    ('pl', u'Polski'),  # Polish
    ('pt-br', u'Português (Brasil)'),  # Portuguese (Brazil)
    ('pt-pt', u'Português (Portugal)'),  # Portuguese (Portugal)
Sarina Canelake's avatar
Sarina Canelake committed
    ('ro', u'română'),  # Romanian
    ('ru', u'Русский'),  # Russian
    ('si', u'සිංහල'),  # Sinhala
    ('sk', u'Slovenčina'),  # Slovak
    ('sl', u'Slovenščina'),  # Slovenian
    ('sq', u'shqip'),  # Albanian
    ('sr', u'Српски'),  # Serbian
    ('sv', u'svenska'),  # Swedish
    ('sw', u'Kiswahili'),  # Swahili
Sarina Canelake's avatar
Sarina Canelake committed
    ('ta', u'தமிழ்'),  # Tamil
    ('te', u'తెలుగు'),  # Telugu
    ('th', u'ไทย'),  # Thai
    ('tr-tr', u'Türkçe (Türkiye)'),  # Turkish (Turkey)
    ('uk', u'Українська'),  # Ukranian
    ('ur', u'اردو'),  # Urdu
    ('vi', u'Tiếng Việt'),  # Vietnamese
    ('uz', u'Ўзбек'),  # Uzbek
Sarina Canelake's avatar
Sarina Canelake committed
    ('zh-cn', u'中文 (简体)'),  # Chinese (China)
    ('zh-hk', u'中文 (香港)'),  # Chinese (Hong Kong)
Sarina Canelake's avatar
Sarina Canelake committed
    ('zh-tw', u'中文 (台灣)'),  # Chinese (Taiwan)
LANGUAGE_DICT = dict(LANGUAGES)

# Languages supported for custom course certificate templates
nadeemshahzad's avatar
nadeemshahzad committed
CERTIFICATE_TEMPLATE_LANGUAGES = {
    'en': 'English',
    'es': 'Español',
}
USE_L10N = True
STATICI18N_FILENAME_FUNCTION = 'statici18n.utils.legacy_filename'
STATICI18N_ROOT = PROJECT_ROOT / "static"
STATICI18N_OUTPUT_DIR = "js/i18n"


# Localization strings (e.g. django.po) are under these directories
def _make_locale_paths(settings):  # pylint: disable=missing-function-docstring
    locale_paths = [settings.REPO_ROOT + '/conf/locale']  # edx-platform/conf/locale/
    if settings.ENABLE_COMPREHENSIVE_THEMING:
        # Add locale paths to settings for comprehensive theming.
        for locale_path in settings.COMPREHENSIVE_THEME_LOCALE_PATHS:
            locale_paths += (path(locale_path), )
    return locale_paths
LOCALE_PATHS = _make_locale_paths
derived('LOCALE_PATHS')

# Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

# Guidelines for translators
TRANSLATORS_GUIDE = 'https://edx.readthedocs.org/projects/edx-developer-guide/en/latest/' \
                    'conventions/internationalization/i18n_translators_guide.html'
#################################### AWS #######################################
# S3BotoStorage insists on a timeout for uploaded assets. We should make it
# permanent instead, but rather than trying to figure out exactly where that
# setting is, I'm just bumping the expiration time to something absurd (100
# years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3
# in the global settings.py
AWS_QUERYSTRING_EXPIRE = 10 * 365 * 24 * 60 * 60  # 10 years
nadeemshahzad's avatar
nadeemshahzad committed
AWS_SES_REGION_NAME = 'us-east-1'
AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com'
AWS_ACCESS_KEY_ID = None
AWS_SECRET_ACCESS_KEY = None
AWS_QUERYSTRING_AUTH = False
AWS_STORAGE_BUCKET_NAME = "SET-ME-PLEASE (ex. bucket-name)"
AWS_S3_CUSTOM_DOMAIN = "SET-ME-PLEASE (ex. bucket-name.s3.amazonaws.com)"
################################# SIMPLEWIKI ###################################
SIMPLE_WIKI_REQUIRE_LOGIN_EDIT = True
SIMPLE_WIKI_REQUIRE_LOGIN_VIEW = False
################################# WIKI ###################################
from course_wiki import settings as course_wiki_settings

WIKI_ACCOUNT_HANDLING = False
WIKI_EDITOR = 'course_wiki.editors.CodeMirror'
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

WIKI_CAN_DELETE = course_wiki_settings.CAN_DELETE
WIKI_CAN_MODERATE = course_wiki_settings.CAN_MODERATE
WIKI_CAN_CHANGE_PERMISSIONS = course_wiki_settings.CAN_CHANGE_PERMISSIONS
WIKI_CAN_ASSIGN = course_wiki_settings.CAN_ASSIGN

WIKI_USE_BOOTSTRAP_SELECT_WIDGET = False
WIKI_LINK_LIVE_LOOKUPS = False
WIKI_LINK_DEFAULT_LEVEL = 2
nadeemshahzad's avatar
nadeemshahzad committed
ZENDESK_URL = ''
ZENDESK_USER = ''
ZENDESK_API_KEY = ''
nadeemshahzad's avatar
nadeemshahzad committed
ZENDESK_OAUTH_ACCESS_TOKEN = ''
Ayub's avatar
Ayub committed
# A mapping of string names to Zendesk Group IDs
# To get the IDs of your groups you can go to
# {zendesk_url}/api/v2/groups.json
ZENDESK_GROUP_ID_MAPPING = {}
##### EMBARGO #####
EMBARGO_SITE_REDIRECT_URL = None

##### shoppingcart Payment #####
nadeemshahzad's avatar
nadeemshahzad committed
PAYMENT_SUPPORT_EMAIL = 'billing@example.com'
# Setting for PAID_COURSE_REGISTRATION, DOES NOT AFFECT VERIFIED STUDENTS
PAID_COURSE_REGISTRATION_CURRENCY = ['usd', '$']
################################# EdxNotes config  #########################

# Configure the LMS to use our stub EdxNotes implementation
EDXNOTES_PUBLIC_API = 'http://localhost:18120/api/v1'
EDXNOTES_INTERNAL_API = 'http://localhost:18120/api/v1'
EDXNOTES_CLIENT_NAME = "edx-notes"
EDXNOTES_CONNECT_TIMEOUT = 0.5  # time in seconds
EDXNOTES_READ_TIMEOUT = 1.5  # time in seconds

########################## Parental controls config  #######################

# The age at which a learner no longer requires parental consent, or None
# if parental consent is never required.
PARENTAL_CONSENT_AGE_LIMIT = 13

Will Daly's avatar
Will Daly committed
######################### Branded Footer ###################################
# Constants for the footer used on the site and shared with other sites
# (such as marketing and the blog) via the branding API.

# URL for OpenEdX displayed in the footer
FOOTER_OPENEDX_URL = "http://open.edx.org"

# URL for the OpenEdX logo image
# We use logo images served from files.edx.org so we can (roughly) track
# how many OpenEdX installations are running.
# Site operators can choose from these logo options:
# * https://files.edx.org/openedx-logos/edx-openedx-logo-tag.png
# * https://files.edx.org/openedx-logos/edx-openedx-logo-tag-light.png"
# * https://files.edx.org/openedx-logos/edx-openedx-logo-tag-dark.png
FOOTER_OPENEDX_LOGO_IMAGE = "https://files.edx.org/openedx-logos/edx-openedx-logo-tag.png"

# This is just a placeholder image.
# Site operators can customize this with their organization's image.
FOOTER_ORGANIZATION_IMAGE = "images/logo.png"
Will Daly's avatar
Will Daly committed

# These are referred to both by the Django asset pipeline
# AND by the branding footer API, which needs to decide which
# version of the CSS to serve.
FOOTER_CSS = {
    "openedx": {
        "ltr": "style-lms-footer",
        "rtl": "style-lms-footer-rtl",
    },
    "edx": {
        "ltr": "style-lms-footer-edx",
        "rtl": "style-lms-footer-edx-rtl",
    },
}

# Cache expiration for the version of the footer served
# by the branding API.
FOOTER_CACHE_TIMEOUT = 30 * 60

# Max age cache control header for the footer (controls browser caching).
FOOTER_BROWSER_CACHE_MAX_AGE = 5 * 60

# Credit api notification cache timeout
CREDIT_NOTIFICATION_CACHE_TIMEOUT = 5 * 60 * 60

################################# Middleware ###################################

Ayub-khan's avatar
Ayub-khan committed
MIDDLEWARE = [
nadeemshahzad's avatar
nadeemshahzad committed
    'openedx.core.lib.x_forwarded_for.middleware.XForwardedForMiddleware',
    # Avoid issue with https://blog.heroku.com/chrome-changes-samesite-cookie
    # Override was found here https://github.com/django/django/pull/11894
    'django_cookies_samesite.middleware.CookiesSameSite',
    'crum.CurrentRequestUserMiddleware',

    # A newer and safer request cache.
    'edx_django_utils.cache.middleware.RequestCacheMiddleware',
    'edx_django_utils.monitoring.middleware.CachedCustomMonitoringMiddleware',
    # Generate code ownership attributes. Keep this immediately after RequestCacheMiddleware.
    'edx_django_utils.monitoring.code_owner.middleware.CodeOwnerMonitoringMiddleware',
    # Cookie monitoring
Tim McCormack's avatar
Tim McCormack committed
    'openedx.core.lib.request_utils.CookieMonitoringMiddleware',
    'mobile_api.middleware.AppVersionUpgrade',
    'openedx.core.djangoapps.header_control.middleware.HeaderControlMiddleware',
    'lms.djangoapps.discussion.django_comment_client.middleware.AjaxExceptionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sites.middleware.CurrentSiteMiddleware',
    'edx_rest_framework_extensions.auth.jwt.middleware.JwtAuthCookieMiddleware',

    # Allows us to define redirects via Django admin
    'django_sites_extensions.middleware.RedirectMiddleware',

    # Instead of SessionMiddleware, we use a more secure version
    # 'django.contrib.sessions.middleware.SessionMiddleware',
    'openedx.core.djangoapps.safe_sessions.middleware.SafeSessionMiddleware',

    # Instead of AuthenticationMiddleware, we use a cached backed version
    #'django.contrib.auth.middleware.AuthenticationMiddleware',
    'openedx.core.djangoapps.cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
    'student.middleware.UserStandingMiddleware',
    'openedx.core.djangoapps.contentserver.middleware.StaticContentServer',
    # Adds user tags to tracking events
    # Must go before TrackMiddleware, to get the context set up
    'openedx.core.djangoapps.user_api.middleware.UserTagsEventContextMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'track.middleware.TrackMiddleware',
Will Daly's avatar
Will Daly committed

    # CORS and CSRF
    'corsheaders.middleware.CorsMiddleware',
    'openedx.core.djangoapps.cors_csrf.middleware.CorsCSRFMiddleware',
    'openedx.core.djangoapps.cors_csrf.middleware.CsrfCrossDomainCookieMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'splash.middleware.SplashMiddleware',
    'openedx.core.djangoapps.geoinfo.middleware.CountryMiddleware',
    'openedx.core.djangoapps.embargo.middleware.EmbargoMiddleware',
    # Allows us to use enterprise customer's language as the learner's default language
    # This middleware must come before `LanguagePreferenceMiddleware` middleware
    'enterprise.middleware.EnterpriseLanguagePreferenceMiddleware',

    # Allows us to set user preferences
    'openedx.core.djangoapps.lang_pref.middleware.LanguagePreferenceMiddleware',
    # Allows us to dark-launch particular languages.
    # Must be after LangPrefMiddleware, so ?preview-lang query params can override
    # user's language preference. ?clear-lang resets to user's language preference.
    'openedx.core.djangoapps.dark_lang.middleware.DarkLangMiddleware',

    # Detects user-requested locale from 'accept-language' header in http request.
    # Must be after DarkLangMiddleware.
    'django.middleware.locale.LocaleMiddleware',
    'lms.djangoapps.discussion.django_comment_client.utils.ViewNameMiddleware',
    'codejail.django_integration.ConfigureCodeJailMiddleware',
Diana Huang's avatar
Diana Huang committed

    # catches any uncaught RateLimitExceptions and returns a 403 instead of a 500
    'ratelimitbackend.middleware.RateLimitMiddleware',
    # for expiring inactive sessions
    'openedx.core.djangoapps.session_inactivity_timeout.middleware.SessionInactivityTimeout',
    # use Django built in clickjacking protection
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # to redirected unenrolled students to the course info page
    'lms.djangoapps.courseware.middleware.CacheCourseIdMiddleware',
    'lms.djangoapps.courseware.middleware.RedirectMiddleware',
    'course_wiki.middleware.WikiAccessMiddleware',
    'openedx.core.djangoapps.theming.middleware.CurrentSiteThemeMiddleware',

Renzo Lucioni's avatar
Renzo Lucioni committed
    'waffle.middleware.WaffleMiddleware',

Robert Raposa's avatar
Robert Raposa committed
    # Enables force_django_cache_miss functionality for TieredCache.
    'edx_django_utils.cache.middleware.TieredCacheMiddleware',

    # Adds monitoring attributes to requests.
    'edx_rest_framework_extensions.middleware.RequestCustomAttributesMiddleware',
Robert Raposa's avatar
Robert Raposa committed
    'edx_rest_framework_extensions.auth.jwt.middleware.EnsureJWTAuthSettingsMiddleware',
    # Handles automatically storing user ids in django-simple-history tables when possible.
    'simple_history.middleware.HistoryRequestMiddleware',

    # This must be last
    'openedx.core.djangoapps.site_configuration.middleware.SessionCookieDomainOverrideMiddleware',
# Clickjacking protection can be disbaled by setting this to 'ALLOW'
X_FRAME_OPTIONS = 'DENY'
# Platform for Privacy Preferences header
P3P_HEADER = 'CP="Open EdX does not have a P3P policy."'

############################### PIPELINE #######################################
PIPELINE = {
    'PIPELINE_ENABLED': True,
    'CSS_COMPRESSOR': None,
    'JS_COMPRESSOR': 'pipeline.compressors.uglifyjs.UglifyJSCompressor',
    # Don't wrap JavaScript as there is code that depends upon updating the global namespace
    'DISABLE_WRAPPER': True,
    # Specify the UglifyJS binary to use
    'UGLIFYJS_BINARY': 'node_modules/.bin/uglifyjs',
}
STATICFILES_STORAGE = 'openedx.core.storage.ProductionStorage'
# List of finder classes that know how to find static files in various locations.
# Note: the pipeline finder is included to be able to discover optimized files
STATICFILES_FINDERS = [
    'openedx.core.djangoapps.theming.finders.ThemeFilesFinder',
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'openedx.core.lib.xblock_pipeline.finder.XBlockPipelineFinder',
    'pipeline.finders.PipelineFinder',
]

from openedx.core.lib.rooted_paths import rooted_glob
Michael Terry's avatar
Michael Terry committed
courseware_js = [
    'js/ajax-error.js',
    'js/courseware.js',
    'js/histogram.js',
    'js/navigation.js',
    'js/modules/tab.js',
]

# Before a student accesses courseware, we do not
# need many of the JS dependencies.  This includes
# only the dependencies used everywhere in the LMS
# (including the dashboard/account/profile pages)
# Currently, this partially duplicates the "main vendor"
# JavaScript file, so only one of the two should be included
# on a page at any time.
# In the future, we will likely refactor this to use
# RequireJS and an optimizer.
base_vendor_js = [
    'common/js/vendor/jquery.js',
    'common/js/vendor/jquery-migrate.js',
    'js/vendor/jquery.cookie.js',
    'js/vendor/url.min.js',
    'common/js/vendor/underscore.js',
    'common/js/vendor/underscore.string.js',
    'common/js/vendor/picturefill.js',

    # Make some edX UI Toolkit utilities available in the global "edx" namespace
    'edx-ui-toolkit/js/utils/global-loader.js',
    'edx-ui-toolkit/js/utils/string-utils.js',
    'edx-ui-toolkit/js/utils/html-utils.js',

    # Finally load RequireJS and dependent vendor libraries
    'common/js/vendor/require.js',
    'js/RequireJS-namespace-undefine.js',
    'js/vendor/URI.min.js',
    'common/js/vendor/backbone.js'
]

main_vendor_js = base_vendor_js + [
    'js/vendor/json2.js',
    'js/vendor/jquery-ui.min.js',
    'js/vendor/jquery.qtip.min.js',
    'js/vendor/jquery.ba-bbq.min.js',
]

# Common files used by both RequireJS code and non-RequireJS code
base_application_js = [
    'js/src/utility.js',
    'js/src/logger.js',
    'js/user_dropdown_v1.js',  # Custom dropdown keyboard handling for legacy pages
    'js/dialog_tab_controls.js',
    'js/src/string_utils.js',
    'js/form.ext.js',
    'js/src/ie_shim.js',
    'js/src/accessibility_tools.js',
    'js/toggle_login_modal.js',
asadiqbal's avatar
asadiqbal committed
    'js/src/lang_edx.js',
Davorin Sego's avatar
Davorin Sego committed
dashboard_js = (
    sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/dashboard/**/*.js'))
discussion_js = (
Michael Terry's avatar
Michael Terry committed
    rooted_glob(PROJECT_ROOT / 'static', 'js/customwmd.js') +
    rooted_glob(PROJECT_ROOT / 'static', 'js/mathjax_accessible.js') +
    rooted_glob(PROJECT_ROOT / 'static', 'js/mathjax_delay_renderer.js') +
    sorted(rooted_glob(COMMON_ROOT / 'static', 'common/js/discussion/**/*.js'))

discussion_vendor_js = [
    'js/Markdown.Converter.js',
    'js/Markdown.Sanitizer.js',
    'js/Markdown.Editor.js',
    'js/vendor/jquery.timeago.js',
    'js/src/jquery.timeago.locale.js',
    'js/vendor/jquery.truncate.js',
    'js/jquery.ajaxfileupload.js',
    'js/split.js'
]

instructor_dash_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/instructor_dashboard/**/*.js'))
verify_student_js = [
    'js/sticky_filter.js',
    'js/query-params.js',
    'js/verify_student/models/verification_model.js',
    'js/verify_student/views/error_view.js',
    'js/verify_student/views/image_input_view.js',
    'js/verify_student/views/webcam_photo_view.js',
    'js/verify_student/views/step_view.js',
    'js/verify_student/views/intro_step_view.js',
    'js/verify_student/views/make_payment_step_view.js',
    'js/verify_student/views/face_photo_step_view.js',
    'js/verify_student/views/id_photo_step_view.js',
    'js/verify_student/views/review_photos_step_view.js',
    'js/verify_student/views/enrollment_confirmation_step_view.js',
    'js/verify_student/views/pay_and_verify_view.js',
    'js/verify_student/pay_and_verify.js',
]

Awais's avatar
Awais committed
reverify_js = [
    'js/verify_student/views/error_view.js',
    'js/verify_student/views/image_input_view.js',
    'js/verify_student/views/webcam_photo_view.js',
    'js/verify_student/views/step_view.js',
    'js/verify_student/views/face_photo_step_view.js',
    'js/verify_student/views/id_photo_step_view.js',
    'js/verify_student/views/review_photos_step_view.js',
    'js/verify_student/views/reverify_success_step_view.js',
    'js/verify_student/models/verification_model.js',
    'js/verify_student/views/reverify_view.js',
    'js/verify_student/reverify.js',
]

incourse_reverify_js = [
Awais's avatar
Awais committed
    'js/verify_student/views/error_view.js',
    'js/verify_student/views/image_input_view.js',
    'js/verify_student/views/webcam_photo_view.js',
    'js/verify_student/models/verification_model.js',
Awais's avatar
Awais committed
    'js/verify_student/views/incourse_reverify_view.js',
    'js/verify_student/incourse_reverify.js',
]

cewing's avatar
cewing committed
ccx_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/ccx/**/*.js'))

Zia Fazal's avatar
Zia Fazal committed
certificates_web_view_js = [
    'common/js/vendor/jquery.js',
    'common/js/vendor/jquery-migrate.js',
Zia Fazal's avatar
Zia Fazal committed
    'js/vendor/jquery.cookie.js',
    'js/src/logger.js',
credit_web_view_js = [
    'common/js/vendor/jquery.js',
    'common/js/vendor/jquery-migrate.js',
    'js/vendor/jquery.cookie.js',
    'js/src/logger.js',
]

PIPELINE['STYLESHEETS'] = {
    'style-vendor': {
        'source_filenames': [
            'css/vendor/font-awesome.css',
            'css/vendor/jquery.qtip.min.css',
        ],
        'output_filename': 'css/lms-style-vendor.css',
    'style-vendor-tinymce-content': {
        'source_filenames': [
            'js/vendor/tinymce/js/tinymce/skins/studio-tmce4/content.min.css'
        ],
        'output_filename': 'css/lms-style-vendor-tinymce-content.css',
    },
    'style-vendor-tinymce-skin': {
        'source_filenames': [
            'js/vendor/tinymce/js/tinymce/skins/studio-tmce4/skin.min.css'
        ],
        'output_filename': 'css/lms-style-vendor-tinymce-skin.css',
    },
        'source_filenames': [
            'css/lms-main-v1.css',
        'output_filename': 'css/lms-main-v1.css',
    'style-main-v1-rtl': {
        'source_filenames': [
            'css/lms-main-v1-rtl.css',
        'output_filename': 'css/lms-main-v1-rtl.css',
    },
        'source_filenames': [
            'js/vendor/CodeMirror/codemirror.css',
            'css/vendor/jquery.treeview.css',
            'css/vendor/ui-lightness/jquery-ui-1.8.22.custom.css',
        ],
        'output_filename': 'css/lms-style-course-vendor.css',
    },
    'style-course': {
        'source_filenames': [
            'css/lms-course.css',
        'output_filename': 'css/lms-course.css',
    'style-course-rtl': {
        'source_filenames': [
            'css/lms-course-rtl.css',
        'output_filename': 'css/lms-course-rtl.css',
    },
    'style-student-notes': {
        'source_filenames': [
            'css/vendor/edxnotes/annotator.min.css',
        ],
        'output_filename': 'css/lms-style-student-notes.css',
    'style-inline-discussion': {
        'source_filenames': [
            'css/discussion/inline-discussion.css',
        ],
        'output_filename': 'css/discussion/inline-discussion.css',
    },
    'style-inline-discussion-rtl': {
        'source_filenames': [
            'css/discussion/inline-discussion-rtl.css',
        ],
        'output_filename': 'css/discussion/inline-discussion-rtl.css',
    },
Will Daly's avatar
Will Daly committed
    FOOTER_CSS['openedx']['ltr']: {
            'css/lms-footer.css',
Will Daly's avatar
Will Daly committed
        'output_filename': 'css/lms-footer.css',
Will Daly's avatar
Will Daly committed
    FOOTER_CSS['openedx']['rtl']: {
            'css/lms-footer-rtl.css',
Will Daly's avatar
Will Daly committed
        'output_filename': 'css/lms-footer-rtl.css'
    },
    FOOTER_CSS['edx']['ltr']: {
        'source_filenames': [
            'css/lms-footer-edx.css',
Will Daly's avatar
Will Daly committed
        ],
        'output_filename': 'css/lms-footer-edx.css'
    },
    FOOTER_CSS['edx']['rtl']: {
        'source_filenames': [
            'css/lms-footer-edx-rtl.css',
Will Daly's avatar
Will Daly committed
        ],
        'output_filename': 'css/lms-footer-edx-rtl.css'
    'style-certificates': {
        'source_filenames': [
            'certificates/css/main-ltr.css',
            'css/vendor/font-awesome.css',
        ],
        'output_filename': 'css/certificates-style.css'
    },
    'style-certificates-rtl': {
        'source_filenames': [
            'certificates/css/main-rtl.css',
            'css/vendor/font-awesome.css',
        ],
        'output_filename': 'css/certificates-style-rtl.css'
    },
    'style-mobile': {
        'source_filenames': [
            'css/lms-mobile.css',
        ],
        'output_filename': 'css/lms-mobile.css',
    },
    'style-mobile-rtl': {
        'source_filenames': [
            'css/lms-mobile-rtl.css',
        ],
        'output_filename': 'css/lms-mobile-rtl.css',
    },
Michael Terry's avatar
Michael Terry committed
common_js = [
    'js/src/ajax_prefix.js',
    'js/src/jquery.immediateDescendents.js',
    'js/src/xproblem.js',
]
xblock_runtime_js = [
    'common/js/xblock/core.js',
    'common/js/xblock/runtime.v1.js',
    'lms/js/xblock/lms.runtime.v1.js',
]
Michael Terry's avatar
Michael Terry committed
lms_application_js = [
    'js/calculator.js',
    'js/feedback_form.js',
    'js/main.js',
]
PIPELINE['JAVASCRIPT'] = {
    'base_application': {
        'source_filenames': base_application_js,
        'output_filename': 'js/lms-base-application.js',
    },
        'source_filenames': (
            common_js + xblock_runtime_js + base_application_js + lms_application_js +
            [
                'js/sticky_filter.js',
                'js/query-params.js',
                'common/js/vendor/moment-with-locales.js',
Gregory Martin's avatar
Gregory Martin committed
                'common/js/vendor/moment-timezone-with-data.js',
        'output_filename': 'js/lms-application.js',
    'courseware': {
        'output_filename': 'js/lms-courseware.js',
    },
    'base_vendor': {
        'source_filenames': base_vendor_js,
        'output_filename': 'js/lms-base-vendor.js',
    'main_vendor': {
        'source_filenames': main_vendor_js,
        'output_filename': 'js/lms-main_vendor.js',
    'module-descriptor-js': {
        'source_filenames': rooted_glob(COMMON_ROOT / 'static/', 'xmodule/descriptors/js/*.js'),
        'output_filename': 'js/lms-module-descriptors.js',
    },
        'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'),
        'output_filename': 'js/discussion.js',
    'discussion_vendor': {
        'source_filenames': discussion_vendor_js,
        'output_filename': 'js/discussion_vendor.js',
    },
    'instructor_dash': {
        'source_filenames': instructor_dash_js,
        'output_filename': 'js/instructor_dash.js',
Will Daly's avatar
Will Daly committed
    'dashboard': {
        'source_filenames': dashboard_js,
        'output_filename': 'js/dashboard.js'
    },
    'verify_student': {
        'source_filenames': verify_student_js,
        'output_filename': 'js/verify_student.js'
Awais's avatar
Awais committed
    },
    'reverify': {
        'source_filenames': reverify_js,
        'output_filename': 'js/reverify.js'
    },
    'incourse_reverify': {
        'source_filenames': incourse_reverify_js,
        'output_filename': 'js/incourse_reverify.js'
cewing's avatar
cewing committed
    'ccx': {
        'source_filenames': ccx_js,
        'output_filename': 'js/ccx.js'
Will Daly's avatar
Will Daly committed
        'source_filenames': ['js/footer-edx.js'],
        'output_filename': 'js/footer-edx.js'
    },
Zia Fazal's avatar
Zia Fazal committed
    'certificates_wv': {
        'source_filenames': certificates_web_view_js,
        'output_filename': 'js/certificates/web_view.js'
    'credit_wv': {
        'source_filenames': credit_web_view_js,
        'output_filename': 'js/credit/web_view.js'
STATICFILES_IGNORE_PATTERNS = (
    "*.py",
    "*.pyc",

    # It would be nice if we could do, for example, "**/*.scss",
    # but these strings get passed down to the `fnmatch` module,
    # which doesn't support that. :(
    # http://docs.python.org/2/library/fnmatch.html
    "sass/*.scss",
    "sass/*/*.scss",
    "sass/*/*/*.scss",
    "sass/*/*/*/*.scss",
    # Ignore tests
    "spec",
    "spec_helpers",

    # Symlinks used by js-test-tool
    "xmodule_js",
################################# DJANGO-REQUIRE ###############################

# The baseUrl to pass to the r.js optimizer, relative to STATIC_ROOT.
REQUIRE_BASE_URL = "./"

# The name of a build profile to use for your project, relative to REQUIRE_BASE_URL.
# A sensible value would be 'app.build.js'. Leave blank to use the built-in default build profile.
# Set to False to disable running the default profile (e.g. if only using it to build Standalone
# Modules)
REQUIRE_BUILD_PROFILE = "lms/js/build.js"

# The name of the require.js script used by your project, relative to REQUIRE_BASE_URL.
REQUIRE_JS = "common/js/vendor/require.js"

# Whether to run django-require in debug mode.
REQUIRE_DEBUG = False

# In production, the Django pipeline appends a file hash to JavaScript file names.
# This makes it difficult for RequireJS to load its requirements, since module names
# specified in JavaScript code do not include the hash.
# For this reason, we calculate the actual path including the hash on the server
# when rendering the page.  We then override the default paths provided to RequireJS
# so it can resolve the module name to the correct URL.
#
# If you want to load JavaScript dependencies using RequireJS
# but you don't want to include those dependencies in the JS bundle for the page,
# then you need to add the js urls in this list.
    'course_bookmarks/js/views/bookmark_button': 'course_bookmarks/js/views/bookmark_button.js',
    'js/views/message_banner': 'js/views/message_banner.js',
    'moment': 'common/js/vendor/moment-with-locales.js',
Gregory Martin's avatar
Gregory Martin committed
    'moment-timezone': 'common/js/vendor/moment-timezone-with-data.js',
    'js/courseware/course_info_events': 'js/courseware/course_info_events.js',
Sanford Student's avatar
Sanford Student committed
    'js/courseware/accordion_events': 'js/courseware/accordion_events.js',
    'js/dateutil_factory': 'js/dateutil_factory.js',
    'js/courseware/link_clicked_events': 'js/courseware/link_clicked_events.js',
    'js/courseware/toggle_element_visibility': 'js/courseware/toggle_element_visibility.js',
    'js/student_account/logistration_factory': 'js/student_account/logistration_factory.js',
    'js/courseware/courseware_factory': 'js/courseware/courseware_factory.js',
    'js/groups/views/cohorts_dashboard_factory': 'js/groups/views/cohorts_dashboard_factory.js',
    'js/groups/discussions_management/discussions_dashboard_factory':
        'js/discussions_management/views/discussions_dashboard_factory.js',
    'draggabilly': 'js/vendor/draggabilly.js',
    'hls': 'common/js/vendor/hls.js'
Brian Jacobel's avatar
Brian Jacobel committed
########################## DJANGO WEBPACK LOADER ##############################

WEBPACK_LOADER = {
    'DEFAULT': {
Loading
Loading full blame...