Merge pull request #26688 from edx/revert-26649-bom-2368

Revert "BOM-2368: pyupgrade in LMS Directory"
This commit is contained in:
Diana Huang
2021-02-23 15:55:04 -05:00
committed by GitHub
21 changed files with 415 additions and 410 deletions

View File

@@ -12,10 +12,9 @@ registration and discovery can work correctly.
# FWIW, this is identical behavior to what happens in Kombu if pkg_resources
# isn't available.
import kombu.utils
kombu.utils.entrypoints = lambda namespace: iter([])
# This will make sure the app is always imported when Django starts so
# that shared_task will use this app, and also ensures that the celery
# singleton is always configured for the LMS.
from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position
kombu.utils.entrypoints = lambda namespace: iter([])

View File

@@ -7,8 +7,8 @@ Taken from: https://celery.readthedocs.org/en/latest/django/first-steps-with-dja
import os
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import
# Set the default Django settings module for the 'celery' program
# and then instantiate the Celery singleton.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lms.envs.production')
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import

View File

@@ -11,7 +11,7 @@ workers = 17
def pre_request(worker, req):
worker.log.info(f"{req.method} {req.path}")
worker.log.info("%s %s" % (req.method, req.path))
def close_all_caches():

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Settings for Bok Choy tests that are used when running LMS.
@@ -34,11 +35,11 @@ TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root"
os.environ['SERVICE_VARIANT'] = 'bok_choy_docker' if 'BOK_CHOY_HOSTNAME' in os.environ else 'bok_choy'
os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml",
config_root=CONFIG_ROOT, service_variant=os.environ['SERVICE_VARIANT'])
os.environ['REVISION_CFG'] = f"{CONFIG_ROOT}/revisions.yml"
os.environ['REVISION_CFG'] = "{config_root}/revisions.yml".format(config_root=CONFIG_ROOT)
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position
######################### Testing overrides ####################################
# Redirect to the test_root folder within the repo
@@ -57,8 +58,8 @@ update_module_store_settings(
default_store=os.environ.get('DEFAULT_STORE', 'draft'),
)
PLATFORM_NAME = ugettext_lazy("édX")
PLATFORM_DESCRIPTION = ugettext_lazy("Open édX Platform")
PLATFORM_NAME = ugettext_lazy(u"édX")
PLATFORM_DESCRIPTION = ugettext_lazy(u"Open édX Platform")
############################ STATIC FILES #############################
@@ -100,9 +101,9 @@ YOUTUBE_HOSTNAME = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1')
# Point the URL used to test YouTube availability to our stub YouTube server
YOUTUBE_PORT = 9080
YOUTUBE['TEST_TIMEOUT'] = 5000
YOUTUBE['API'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/get_youtube_api/"
YOUTUBE['METADATA_URL'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_youtube/"
YOUTUBE['TEXT_API']['url'] = f"{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_transcripts_youtube/"
YOUTUBE['API'] = "http://{0}:{1}/get_youtube_api/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
YOUTUBE['METADATA_URL'] = "http://{0}:{1}/test_youtube/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
YOUTUBE['TEXT_API']['url'] = "{0}:{1}/test_transcripts_youtube/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
############################# SECURITY SETTINGS ################################
# Default to advanced security in common.py, so tests can reset here to use

View File

@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
"""
Settings for Bok Choy tests that are used when running Studio in Docker-based devstack.
"""
# noinspection PyUnresolvedReferences
from .bok_choy import * # pylint: disable=wildcard-import
CMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_CMS_PORT', 8031))
LMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_LMS_PORT', 8003))
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LOGIN_REDIRECT_WHITELIST = [CMS_BASE]
SITE_NAME = LMS_BASE
@@ -22,6 +24,6 @@ LOGGING['loggers']['tracking']['handlers'] = ['console']
# Point the URL used to test YouTube availability to our stub YouTube server
BOK_CHOY_HOST = os.environ['BOK_CHOY_HOSTNAME']
YOUTUBE['API'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/get_youtube_api/"
YOUTUBE['METADATA_URL'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_youtube/"
YOUTUBE['TEXT_API']['url'] = f"{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_transcripts_youtube/"
YOUTUBE['API'] = "http://{}:{}/get_youtube_api/".format(BOK_CHOY_HOST, YOUTUBE_PORT)
YOUTUBE['METADATA_URL'] = "http://{}:{}/test_youtube/".format(BOK_CHOY_HOST, YOUTUBE_PORT)
YOUTUBE['TEXT_API']['url'] = "{}:{}/test_transcripts_youtube/".format(BOK_CHOY_HOST, YOUTUBE_PORT)

View File

@@ -1,3 +1,4 @@
# -*- 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,
@@ -29,43 +30,29 @@ Longer TODO:
import importlib.util
import os
import sys
################################## TEMPLATE CONFIGURATION #####################################
# Mako templating
import tempfile # pylint: disable=wrong-import-position,wrong-import-order
import os
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 edx_django_utils.plugins import ( # pylint: disable=wrong-import-position,wrong-import-order
add_plugins,
get_plugin_apps
)
from enterprise.constants import (
ENTERPRISE_ADMIN_ROLE,
ENTERPRISE_CATALOG_ADMIN_ROLE,
ENTERPRISE_DASHBOARD_ADMIN_ROLE,
ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE,
ENTERPRISE_OPERATOR_ROLE,
ENTERPRISE_REPORTING_CONFIG_ADMIN_ROLE
ENTERPRISE_REPORTING_CONFIG_ADMIN_ROLE,
ENTERPRISE_OPERATOR_ROLE
)
from path import Path as path
################################# WIKI ###################################
from lms.djangoapps.course_wiki import settings as course_wiki_settings # pylint: disable=wrong-import-position
from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
from openedx.core.constants import COURSE_ID_PATTERN, COURSE_KEY_PATTERN, COURSE_KEY_REGEX
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType # pylint: disable=wrong-import-position
from openedx.core.djangoapps.theming.helpers_dirs import get_theme_base_dirs_from_settings, get_themes_unchecked
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.lib.rooted_paths import rooted_glob # pylint: disable=wrong-import-position
from openedx.core.release import doc_version
from xmodule.modulestore import prefer_xmodules
# 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.x_module import XModuleMixin
from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
################################### FEATURES ###################################
# .. setting_name: PLATFORM_NAME
@@ -1088,6 +1075,9 @@ OAUTH_EXPIRE_PUBLIC_CLIENT_DAYS = 30
TPA_PROVIDER_BURST_THROTTLE = '10/min'
TPA_PROVIDER_SUSTAINED_THROTTLE = '50/hr'
################################## TEMPLATE CONFIGURATION #####################################
# Mako templating
import tempfile # pylint: disable=wrong-import-position,wrong-import-order
MAKO_MODULE_DIR = os.path.join(tempfile.gettempdir(), 'mako_lms')
MAKO_TEMPLATE_DIRS_BASE = [
PROJECT_ROOT / 'templates',
@@ -1282,13 +1272,13 @@ WIKI_ENABLED = True
COURSE_MODE_DEFAULTS = {
'bulk_sku': None,
'currency': 'usd',
'currency': u'usd',
'description': None,
'expiration_datetime': None,
'min_price': 0,
'name': _('Audit'),
'name': _(u'Audit'),
'sku': None,
'slug': 'audit',
'slug': u'audit',
'suggested_prices': '',
}
@@ -1305,7 +1295,7 @@ USAGE_ID_PATTERN = r'(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|
# 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 = fr'(?P<username>{USERNAME_REGEX_PARTIAL})'
USERNAME_PATTERN = r'(?P<username>{regex})'.format(regex=USERNAME_REGEX_PARTIAL)
############################## EVENT TRACKING #################################
@@ -1397,6 +1387,12 @@ COURSE_LISTINGS = {}
############# 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.
@@ -1658,87 +1654,87 @@ LANGUAGE_COOKIE = "openedx-language-preference"
# Sourced from http://www.localeplanet.com/icu/ and wikipedia
LANGUAGES = [
('en', 'English'),
('rtl', 'Right-to-Left Test Language'),
('eo', 'Dummy Language (Esperanto)'), # Dummy languaged used for testing
('fake2', 'Fake translations'), # Another dummy language for testing (not pushed to prod)
('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)
('am', 'አማርኛ'), # Amharic
('ar', 'العربية'), # Arabic
('az', 'azərbaycanca'), # Azerbaijani
('bg-bg', 'български (България)'), # Bulgarian (Bulgaria)
('bn-bd', 'বাংলা (বাংলাদেশ)'), # Bengali (Bangladesh)
('bn-in', 'বাংলা (ভারত)'), # Bengali (India)
('bs', 'bosanski'), # Bosnian
('ca', 'Català'), # Catalan
('ca@valencia', 'Català (València)'), # Catalan (Valencia)
('cs', 'Čeština'), # Czech
('cy', 'Cymraeg'), # Welsh
('da', 'dansk'), # Danish
('de-de', 'Deutsch (Deutschland)'), # German (Germany)
('el', 'Ελληνικά'), # Greek
('en-uk', 'English (United Kingdom)'), # English (United Kingdom)
('en@lolcat', 'LOLCAT English'), # LOLCAT English
('en@pirate', 'Pirate English'), # Pirate English
('es-419', 'Español (Latinoamérica)'), # Spanish (Latin America)
('es-ar', 'Español (Argentina)'), # Spanish (Argentina)
('es-ec', 'Español (Ecuador)'), # Spanish (Ecuador)
('es-es', 'Español (España)'), # Spanish (Spain)
('es-mx', 'Español (México)'), # Spanish (Mexico)
('es-pe', 'Español (Perú)'), # Spanish (Peru)
('et-ee', 'Eesti (Eesti)'), # Estonian (Estonia)
('eu-es', 'euskara (Espainia)'), # Basque (Spain)
('fa', 'فارسی'), # Persian
('fa-ir', 'فارسی (ایران)'), # Persian (Iran)
('fi-fi', 'Suomi (Suomi)'), # Finnish (Finland)
('fil', 'Filipino'), # Filipino
('fr', 'Français'), # French
('gl', 'Galego'), # Galician
('gu', 'ગુજરાતી'), # Gujarati
('he', 'עברית'), # Hebrew
('hi', 'हिन्दी'), # Hindi
('hr', 'hrvatski'), # Croatian
('hu', 'magyar'), # Hungarian
('hy-am', 'Հայերեն (Հայաստան)'), # Armenian (Armenia)
('id', 'Bahasa Indonesia'), # Indonesian
('it-it', 'Italiano (Italia)'), # Italian (Italy)
('ja-jp', '日本語 (日本)'), # Japanese (Japan)
('kk-kz', 'қазақ тілі (Қазақстан)'), # Kazakh (Kazakhstan)
('km-kh', 'ភាសាខ្មែរ (កម្ពុជា)'), # Khmer (Cambodia)
('kn', 'ಕನ್ನಡ'), # Kannada
('ko-kr', '한국어 (대한민국)'), # Korean (Korea)
('lt-lt', 'Lietuvių (Lietuva)'), # Lithuanian (Lithuania)
('ml', 'മലയാളം'), # Malayalam
('mn', 'Монгол хэл'), # Mongolian
('mr', 'मराठी'), # Marathi
('ms', 'Bahasa Melayu'), # Malay
('nb', 'Norsk bokmål'), # Norwegian Bokmål
('ne', 'नेपाली'), # Nepali
('nl-nl', 'Nederlands (Nederland)'), # Dutch (Netherlands)
('or', 'ଓଡ଼ିଆ'), # Oriya
('pl', 'Polski'), # Polish
('pt-br', 'Português (Brasil)'), # Portuguese (Brazil)
('pt-pt', 'Português (Portugal)'), # Portuguese (Portugal)
('ro', 'română'), # Romanian
('ru', 'Русский'), # Russian
('si', 'සිංහල'), # Sinhala
('sk', 'Slovenčina'), # Slovak
('sl', 'Slovenščina'), # Slovenian
('sq', 'shqip'), # Albanian
('sr', 'Српски'), # Serbian
('sv', 'svenska'), # Swedish
('sw', 'Kiswahili'), # Swahili
('ta', 'தமிழ்'), # Tamil
('te', 'తెలుగు'), # Telugu
('th', 'ไทย'), # Thai
('tr-tr', 'Türkçe (Türkiye)'), # Turkish (Turkey)
('uk', 'Українська'), # Ukranian
('ur', 'اردو'), # Urdu
('vi', 'Tiếng Việt'), # Vietnamese
('uz', 'Ўзбек'), # Uzbek
('zh-cn', '中文 (简体)'), # Chinese (China)
('zh-hk', '中文 (香港)'), # Chinese (Hong Kong)
('zh-tw', '中文 (台灣)'), # Chinese (Taiwan)
('am', u'አማርኛ'), # Amharic
('ar', u'العربية'), # Arabic
('az', u'azərbaycanca'), # Azerbaijani
('bg-bg', u'български (България)'), # Bulgarian (Bulgaria)
('bn-bd', u'বাংলা (বাংলাদেশ)'), # Bengali (Bangladesh)
('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
('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
('gu', u'ગુજરાતી'), # Gujarati
('he', u'עברית'), # Hebrew
('hi', u'हिन्दी'), # Hindi
('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)
('ja-jp', u'日本語 (日本)'), # Japanese (Japan)
('kk-kz', u'қазақ тілі (Қазақстан)'), # Kazakh (Kazakhstan)
('km-kh', u'ភាសាខ្មែរ (កម្ពុជា)'), # Khmer (Cambodia)
('kn', u'ಕನ್ನಡ'), # Kannada
('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)
('or', u'ଓଡ଼ିଆ'), # Oriya
('pl', u'Polski'), # Polish
('pt-br', u'Português (Brasil)'), # Portuguese (Brazil)
('pt-pt', u'Português (Portugal)'), # Portuguese (Portugal)
('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
('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
('zh-cn', u'中文 (简体)'), # Chinese (China)
('zh-hk', u'中文 (香港)'), # Chinese (Hong Kong)
('zh-tw', u'中文 (台灣)'), # Chinese (Taiwan)
]
LANGUAGE_DICT = dict(LANGUAGES)
@@ -1794,6 +1790,8 @@ AWS_S3_CUSTOM_DOMAIN = "SET-ME-PLEASE (ex. bucket-name.s3.amazonaws.com)"
SIMPLE_WIKI_REQUIRE_LOGIN_EDIT = True
SIMPLE_WIKI_REQUIRE_LOGIN_VIEW = False
################################# WIKI ###################################
from lms.djangoapps.course_wiki import settings as course_wiki_settings # pylint: disable=wrong-import-position
# .. toggle_name: WIKI_ACCOUNT_HANDLING
# .. toggle_implementation: DjangoSetting
@@ -2093,6 +2091,7 @@ STATICFILES_FINDERS = [
'pipeline.finders.PipelineFinder',
]
from openedx.core.lib.rooted_paths import rooted_glob # pylint: disable=wrong-import-position
courseware_js = [
'js/ajax-error.js',
@@ -3173,28 +3172,28 @@ SOCIAL_MEDIA_FOOTER_DISPLAY = {
# translate this the way that Facebook advertises in your language.
"title": _("Facebook"),
"icon": "fa-facebook-square",
"action": _("Like {platform_name} on Facebook")
"action": _(u"Like {platform_name} on Facebook")
},
"twitter": {
# Translators: This is the website name of www.twitter.com. Please
# translate this the way that Twitter advertises in your language.
"title": _("Twitter"),
"icon": "fa-twitter-square",
"action": _("Follow {platform_name} on Twitter")
"action": _(u"Follow {platform_name} on Twitter")
},
"linkedin": {
# Translators: This is the website name of www.linkedin.com. Please
# translate this the way that LinkedIn advertises in your language.
"title": _("LinkedIn"),
"icon": "fa-linkedin-square",
"action": _("Follow {platform_name} on LinkedIn")
"action": _(u"Follow {platform_name} on LinkedIn")
},
"instagram": {
# Translators: This is the website name of www.instagram.com. Please
# translate this the way that Instagram advertises in your language.
"title": _("Instagram"),
"icon": "fa-instagram",
"action": _("Follow {platform_name} on Instagram")
"action": _(u"Follow {platform_name} on Instagram")
},
"tumblr": {
# Translators: This is the website name of www.tumblr.com. Please
@@ -3213,7 +3212,7 @@ SOCIAL_MEDIA_FOOTER_DISPLAY = {
# translate this the way that Reddit advertises in your language.
"title": _("Reddit"),
"icon": "fa-reddit-square",
"action": _("Subscribe to the {platform_name} subreddit"),
"action": _(u"Subscribe to the {platform_name} subreddit"),
},
"vk": {
# Translators: This is the website name of https://vk.com. Please
@@ -3232,7 +3231,7 @@ SOCIAL_MEDIA_FOOTER_DISPLAY = {
# translate this the way that YouTube advertises in your language.
"title": _("Youtube"),
"icon": "fa-youtube-square",
"action": _("Subscribe to the {platform_name} YouTube channel")
"action": _(u"Subscribe to the {platform_name} YouTube channel")
}
}
@@ -3503,192 +3502,192 @@ VIDEO_TRANSCRIPTS_MAX_AGE = 31536000
# Note that this is used as the set of choices to the `code` field of the
# `LanguageProficiency` model.
ALL_LANGUAGES = [
["aa", "Afar"],
["ab", "Abkhazian"],
["af", "Afrikaans"],
["ak", "Akan"],
["sq", "Albanian"],
["am", "Amharic"],
["ar", "Arabic"],
["an", "Aragonese"],
["hy", "Armenian"],
["as", "Assamese"],
["av", "Avaric"],
["ae", "Avestan"],
["ay", "Aymara"],
["az", "Azerbaijani"],
["ba", "Bashkir"],
["bm", "Bambara"],
["eu", "Basque"],
["be", "Belarusian"],
["bn", "Bengali"],
["bh", "Bihari languages"],
["bi", "Bislama"],
["bs", "Bosnian"],
["br", "Breton"],
["bg", "Bulgarian"],
["my", "Burmese"],
["ca", "Catalan"],
["ch", "Chamorro"],
["ce", "Chechen"],
["zh", "Chinese"],
["zh_HANS", "Simplified Chinese"],
["zh_HANT", "Traditional Chinese"],
["cu", "Church Slavic"],
["cv", "Chuvash"],
["kw", "Cornish"],
["co", "Corsican"],
["cr", "Cree"],
["cs", "Czech"],
["da", "Danish"],
["dv", "Divehi"],
["nl", "Dutch"],
["dz", "Dzongkha"],
["en", "English"],
["eo", "Esperanto"],
["et", "Estonian"],
["ee", "Ewe"],
["fo", "Faroese"],
["fj", "Fijian"],
["fi", "Finnish"],
["fr", "French"],
["fy", "Western Frisian"],
["ff", "Fulah"],
["ka", "Georgian"],
["de", "German"],
["gd", "Gaelic"],
["ga", "Irish"],
["gl", "Galician"],
["gv", "Manx"],
["el", "Greek"],
["gn", "Guarani"],
["gu", "Gujarati"],
["ht", "Haitian"],
["ha", "Hausa"],
["he", "Hebrew"],
["hz", "Herero"],
["hi", "Hindi"],
["ho", "Hiri Motu"],
["hr", "Croatian"],
["hu", "Hungarian"],
["ig", "Igbo"],
["is", "Icelandic"],
["io", "Ido"],
["ii", "Sichuan Yi"],
["iu", "Inuktitut"],
["ie", "Interlingue"],
["ia", "Interlingua"],
["id", "Indonesian"],
["ik", "Inupiaq"],
["it", "Italian"],
["jv", "Javanese"],
["ja", "Japanese"],
["kl", "Kalaallisut"],
["kn", "Kannada"],
["ks", "Kashmiri"],
["kr", "Kanuri"],
["kk", "Kazakh"],
["km", "Central Khmer"],
["ki", "Kikuyu"],
["rw", "Kinyarwanda"],
["ky", "Kirghiz"],
["kv", "Komi"],
["kg", "Kongo"],
["ko", "Korean"],
["kj", "Kuanyama"],
["ku", "Kurdish"],
["lo", "Lao"],
["la", "Latin"],
["lv", "Latvian"],
["li", "Limburgan"],
["ln", "Lingala"],
["lt", "Lithuanian"],
["lb", "Luxembourgish"],
["lu", "Luba-Katanga"],
["lg", "Ganda"],
["mk", "Macedonian"],
["mh", "Marshallese"],
["ml", "Malayalam"],
["mi", "Maori"],
["mr", "Marathi"],
["ms", "Malay"],
["mg", "Malagasy"],
["mt", "Maltese"],
["mn", "Mongolian"],
["na", "Nauru"],
["nv", "Navajo"],
["nr", "Ndebele, South"],
["nd", "Ndebele, North"],
["ng", "Ndonga"],
["ne", "Nepali"],
["nn", "Norwegian Nynorsk"],
["nb", "Bokmål, Norwegian"],
["no", "Norwegian"],
["ny", "Chichewa"],
["oc", "Occitan"],
["oj", "Ojibwa"],
["or", "Oriya"],
["om", "Oromo"],
["os", "Ossetian"],
["pa", "Panjabi"],
["fa", "Persian"],
["pi", "Pali"],
["pl", "Polish"],
["pt", "Portuguese"],
["ps", "Pushto"],
["qu", "Quechua"],
["rm", "Romansh"],
["ro", "Romanian"],
["rn", "Rundi"],
["ru", "Russian"],
["sg", "Sango"],
["sa", "Sanskrit"],
["si", "Sinhala"],
["sk", "Slovak"],
["sl", "Slovenian"],
["se", "Northern Sami"],
["sm", "Samoan"],
["sn", "Shona"],
["sd", "Sindhi"],
["so", "Somali"],
["st", "Sotho, Southern"],
["es", "Spanish"],
["sc", "Sardinian"],
["sr", "Serbian"],
["ss", "Swati"],
["su", "Sundanese"],
["sw", "Swahili"],
["sv", "Swedish"],
["ty", "Tahitian"],
["ta", "Tamil"],
["tt", "Tatar"],
["te", "Telugu"],
["tg", "Tajik"],
["tl", "Tagalog"],
["th", "Thai"],
["bo", "Tibetan"],
["ti", "Tigrinya"],
["to", "Tonga (Tonga Islands)"],
["tn", "Tswana"],
["ts", "Tsonga"],
["tk", "Turkmen"],
["tr", "Turkish"],
["tw", "Twi"],
["ug", "Uighur"],
["uk", "Ukrainian"],
["ur", "Urdu"],
["uz", "Uzbek"],
["ve", "Venda"],
["vi", "Vietnamese"],
["vo", "Volapük"],
["cy", "Welsh"],
["wa", "Walloon"],
["wo", "Wolof"],
["xh", "Xhosa"],
["yi", "Yiddish"],
["yo", "Yoruba"],
["za", "Zhuang"],
["zu", "Zulu"]
[u"aa", u"Afar"],
[u"ab", u"Abkhazian"],
[u"af", u"Afrikaans"],
[u"ak", u"Akan"],
[u"sq", u"Albanian"],
[u"am", u"Amharic"],
[u"ar", u"Arabic"],
[u"an", u"Aragonese"],
[u"hy", u"Armenian"],
[u"as", u"Assamese"],
[u"av", u"Avaric"],
[u"ae", u"Avestan"],
[u"ay", u"Aymara"],
[u"az", u"Azerbaijani"],
[u"ba", u"Bashkir"],
[u"bm", u"Bambara"],
[u"eu", u"Basque"],
[u"be", u"Belarusian"],
[u"bn", u"Bengali"],
[u"bh", u"Bihari languages"],
[u"bi", u"Bislama"],
[u"bs", u"Bosnian"],
[u"br", u"Breton"],
[u"bg", u"Bulgarian"],
[u"my", u"Burmese"],
[u"ca", u"Catalan"],
[u"ch", u"Chamorro"],
[u"ce", u"Chechen"],
[u"zh", u"Chinese"],
[u"zh_HANS", u"Simplified Chinese"],
[u"zh_HANT", u"Traditional Chinese"],
[u"cu", u"Church Slavic"],
[u"cv", u"Chuvash"],
[u"kw", u"Cornish"],
[u"co", u"Corsican"],
[u"cr", u"Cree"],
[u"cs", u"Czech"],
[u"da", u"Danish"],
[u"dv", u"Divehi"],
[u"nl", u"Dutch"],
[u"dz", u"Dzongkha"],
[u"en", u"English"],
[u"eo", u"Esperanto"],
[u"et", u"Estonian"],
[u"ee", u"Ewe"],
[u"fo", u"Faroese"],
[u"fj", u"Fijian"],
[u"fi", u"Finnish"],
[u"fr", u"French"],
[u"fy", u"Western Frisian"],
[u"ff", u"Fulah"],
[u"ka", u"Georgian"],
[u"de", u"German"],
[u"gd", u"Gaelic"],
[u"ga", u"Irish"],
[u"gl", u"Galician"],
[u"gv", u"Manx"],
[u"el", u"Greek"],
[u"gn", u"Guarani"],
[u"gu", u"Gujarati"],
[u"ht", u"Haitian"],
[u"ha", u"Hausa"],
[u"he", u"Hebrew"],
[u"hz", u"Herero"],
[u"hi", u"Hindi"],
[u"ho", u"Hiri Motu"],
[u"hr", u"Croatian"],
[u"hu", u"Hungarian"],
[u"ig", u"Igbo"],
[u"is", u"Icelandic"],
[u"io", u"Ido"],
[u"ii", u"Sichuan Yi"],
[u"iu", u"Inuktitut"],
[u"ie", u"Interlingue"],
[u"ia", u"Interlingua"],
[u"id", u"Indonesian"],
[u"ik", u"Inupiaq"],
[u"it", u"Italian"],
[u"jv", u"Javanese"],
[u"ja", u"Japanese"],
[u"kl", u"Kalaallisut"],
[u"kn", u"Kannada"],
[u"ks", u"Kashmiri"],
[u"kr", u"Kanuri"],
[u"kk", u"Kazakh"],
[u"km", u"Central Khmer"],
[u"ki", u"Kikuyu"],
[u"rw", u"Kinyarwanda"],
[u"ky", u"Kirghiz"],
[u"kv", u"Komi"],
[u"kg", u"Kongo"],
[u"ko", u"Korean"],
[u"kj", u"Kuanyama"],
[u"ku", u"Kurdish"],
[u"lo", u"Lao"],
[u"la", u"Latin"],
[u"lv", u"Latvian"],
[u"li", u"Limburgan"],
[u"ln", u"Lingala"],
[u"lt", u"Lithuanian"],
[u"lb", u"Luxembourgish"],
[u"lu", u"Luba-Katanga"],
[u"lg", u"Ganda"],
[u"mk", u"Macedonian"],
[u"mh", u"Marshallese"],
[u"ml", u"Malayalam"],
[u"mi", u"Maori"],
[u"mr", u"Marathi"],
[u"ms", u"Malay"],
[u"mg", u"Malagasy"],
[u"mt", u"Maltese"],
[u"mn", u"Mongolian"],
[u"na", u"Nauru"],
[u"nv", u"Navajo"],
[u"nr", u"Ndebele, South"],
[u"nd", u"Ndebele, North"],
[u"ng", u"Ndonga"],
[u"ne", u"Nepali"],
[u"nn", u"Norwegian Nynorsk"],
[u"nb", u"Bokmål, Norwegian"],
[u"no", u"Norwegian"],
[u"ny", u"Chichewa"],
[u"oc", u"Occitan"],
[u"oj", u"Ojibwa"],
[u"or", u"Oriya"],
[u"om", u"Oromo"],
[u"os", u"Ossetian"],
[u"pa", u"Panjabi"],
[u"fa", u"Persian"],
[u"pi", u"Pali"],
[u"pl", u"Polish"],
[u"pt", u"Portuguese"],
[u"ps", u"Pushto"],
[u"qu", u"Quechua"],
[u"rm", u"Romansh"],
[u"ro", u"Romanian"],
[u"rn", u"Rundi"],
[u"ru", u"Russian"],
[u"sg", u"Sango"],
[u"sa", u"Sanskrit"],
[u"si", u"Sinhala"],
[u"sk", u"Slovak"],
[u"sl", u"Slovenian"],
[u"se", u"Northern Sami"],
[u"sm", u"Samoan"],
[u"sn", u"Shona"],
[u"sd", u"Sindhi"],
[u"so", u"Somali"],
[u"st", u"Sotho, Southern"],
[u"es", u"Spanish"],
[u"sc", u"Sardinian"],
[u"sr", u"Serbian"],
[u"ss", u"Swati"],
[u"su", u"Sundanese"],
[u"sw", u"Swahili"],
[u"sv", u"Swedish"],
[u"ty", u"Tahitian"],
[u"ta", u"Tamil"],
[u"tt", u"Tatar"],
[u"te", u"Telugu"],
[u"tg", u"Tajik"],
[u"tl", u"Tagalog"],
[u"th", u"Thai"],
[u"bo", u"Tibetan"],
[u"ti", u"Tigrinya"],
[u"to", u"Tonga (Tonga Islands)"],
[u"tn", u"Tswana"],
[u"ts", u"Tsonga"],
[u"tk", u"Turkmen"],
[u"tr", u"Turkish"],
[u"tw", u"Twi"],
[u"ug", u"Uighur"],
[u"uk", u"Ukrainian"],
[u"ur", u"Urdu"],
[u"uz", u"Uzbek"],
[u"ve", u"Venda"],
[u"vi", u"Vietnamese"],
[u"vo", u"Volapük"],
[u"cy", u"Welsh"],
[u"wa", u"Walloon"],
[u"wo", u"Wolof"],
[u"xh", u"Xhosa"],
[u"yi", u"Yiddish"],
[u"yo", u"Yoruba"],
[u"za", u"Zhuang"],
[u"zu", u"Zulu"]
]
@@ -3905,7 +3904,7 @@ ECOMMERCE_SERVICE_WORKER_USERNAME = 'ecommerce_worker'
ECOMMERCE_API_SIGNING_KEY = 'SET-ME-PLEASE'
COURSE_CATALOG_URL_ROOT = 'http://localhost:8008'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
CREDENTIALS_INTERNAL_SERVICE_URL = 'http://localhost:8005'
CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:8005'
@@ -4235,17 +4234,17 @@ ENTERPRISE_ALL_SERVICE_USERNAMES = [
# which are not provided by the Enterprise service. These settings provide base values
# for those features.
ENTERPRISE_PLATFORM_WELCOME_TEMPLATE = _('Welcome to {platform_name}.')
ENTERPRISE_PLATFORM_WELCOME_TEMPLATE = _(u'Welcome to {platform_name}.')
ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE = _(
'You have left the {start_bold}{enterprise_name}{end_bold} website and are now on the {platform_name} site. '
'{enterprise_name} has partnered with {platform_name} to offer you high-quality, always available learning '
'programs to help you advance your knowledge and career. '
'{line_break}Please note that {platform_name} has a different {privacy_policy_link_start}Privacy Policy'
'{privacy_policy_link_end} from {enterprise_name}.'
u'You have left the {start_bold}{enterprise_name}{end_bold} website and are now on the {platform_name} site. '
u'{enterprise_name} has partnered with {platform_name} to offer you high-quality, always available learning '
u'programs to help you advance your knowledge and career. '
u'{line_break}Please note that {platform_name} has a different {privacy_policy_link_start}Privacy Policy'
u'{privacy_policy_link_end} from {enterprise_name}.'
)
ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE = _(
'{start_bold}{enterprise_name}{end_bold} has partnered with {start_bold}{platform_name}{end_bold} '
'to offer you high-quality learning opportunities from the world\'s best institutions and universities.'
u'{start_bold}{enterprise_name}{end_bold} has partnered with {start_bold}{platform_name}{end_bold} '
u'to offer you high-quality learning opportunities from the world\'s best institutions and universities.'
)
ENTERPRISE_TAGLINE = ''
ENTERPRISE_EXCLUDED_REGISTRATION_FIELDS = {
@@ -4545,6 +4544,8 @@ SYSTEM_WIDE_ROLE_CLASSES = []
############## Plugin Django Apps #########################
from edx_django_utils.plugins import get_plugin_apps, add_plugins # pylint: disable=wrong-import-position,wrong-import-order
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType # pylint: disable=wrong-import-position
INSTALLED_APPS.extend(get_plugin_apps(ProjectType.LMS))
add_plugins(__name__, ProjectType.LMS, SettingsType.COMMON)

View File

@@ -8,6 +8,7 @@ import logging
from os.path import abspath, dirname, join
from corsheaders.defaults import default_headers as corsheaders_default_headers
# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value
#####################################################################
from edx_django_utils.plugins import add_plugins
@@ -33,9 +34,9 @@ SITE_NAME = LMS_BASE
CELERY_ALWAYS_EAGER = True
HTTPS = 'off'
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
ENTERPRISE_API_URL = f'{LMS_INTERNAL_ROOT_URL}/enterprise/api/v1/'
ENTERPRISE_API_URL = '{}/enterprise/api/v1/'.format(LMS_INTERNAL_ROOT_URL)
IDA_LOGOUT_URI_LIST = [
'http://localhost:18130/logout/', # ecommerce
'http://localhost:18150/logout/', # credentials
@@ -279,10 +280,10 @@ LOGIN_REDIRECT_WHITELIST = [
###################### JWTs ######################
JWT_AUTH.update({
'JWT_AUDIENCE': 'lms-key',
'JWT_ISSUER': f'{LMS_ROOT_URL}/oauth2',
'JWT_ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'JWT_ISSUERS': [{
'AUDIENCE': 'lms-key',
'ISSUER': f'{LMS_ROOT_URL}/oauth2',
'ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'SECRET_KEY': 'lms-secret',
}],
'JWT_SECRET_KEY': 'lms-secret',
@@ -381,7 +382,7 @@ ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
CREDENTIALS_SERVICE_USERNAME = 'credentials_worker'
COURSE_CATALOG_URL_ROOT = 'http://edx.devstack.discovery:18381'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", SYSTEM_WIDE_ROLE_CLASSES)
SYSTEM_WIDE_ROLE_CLASSES.append(

View File

@@ -7,6 +7,7 @@ import logging
from os.path import abspath, dirname, join
from corsheaders.defaults import default_headers as corsheaders_default_headers
# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value
#####################################################################
from edx_django_utils.plugins import add_plugins
@@ -32,9 +33,9 @@ SITE_NAME = LMS_BASE
CELERY_ALWAYS_EAGER = True
HTTPS = 'off'
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
ENTERPRISE_API_URL = f'{LMS_INTERNAL_ROOT_URL}/enterprise/api/v1/'
ENTERPRISE_API_URL = '{}/enterprise/api/v1/'.format(LMS_INTERNAL_ROOT_URL)
IDA_LOGOUT_URI_LIST = [
'http://localhost:18130/logout/', # ecommerce
'http://localhost:18150/logout/', # credentials
@@ -217,10 +218,10 @@ LOGIN_REDIRECT_WHITELIST = [CMS_BASE]
###################### JWTs ######################
JWT_AUTH.update({
'JWT_AUDIENCE': 'lms-key',
'JWT_ISSUER': f'{LMS_ROOT_URL}/oauth2',
'JWT_ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'JWT_ISSUERS': [{
'AUDIENCE': 'lms-key',
'ISSUER': f'{LMS_ROOT_URL}/oauth2',
'ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'SECRET_KEY': 'lms-secret',
}],
'JWT_SECRET_KEY': 'lms-secret',
@@ -320,7 +321,7 @@ ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
CREDENTIALS_SERVICE_USERNAME = 'credentials_worker'
COURSE_CATALOG_URL_ROOT = 'http://edx.devstack.discovery:18381'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", SYSTEM_WIDE_ROLE_CLASSES)
SYSTEM_WIDE_ROLE_CLASSES.append(

View File

@@ -21,10 +21,9 @@ invoked each time that changes have been made.
import os # lint-amnesty, pylint: disable=unused-import
from .devstack import * # pylint: disable=wildcard-import
########################## Devstack settings ###################################
from .devstack import * # pylint: disable=wildcard-import
TEST_ROOT = REPO_ROOT / "test_root"

View File

@@ -14,6 +14,9 @@ In two separate processes on devstack:
import os # lint-amnesty, pylint: disable=unused-import
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=wildcard-import, unused-wildcard-import
from lms.envs.devstack import *
# Require a separate celery worker

View File

@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
"""
This is the default template for our main set of AWS servers.
@@ -41,7 +43,7 @@ def get_env_setting(setting):
try:
return os.environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
error_msg = u"Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg) # lint-amnesty, pylint: disable=raise-missing-from
################################ ALWAYS THE SAME ##############################
@@ -133,11 +135,11 @@ CELERYD_PREFETCH_MULTIPLIER = 1
QUEUE_VARIANT = CONFIG_PREFIX.lower()
CELERY_DEFAULT_EXCHANGE = f'edx.{QUEUE_VARIANT}core'
CELERY_DEFAULT_EXCHANGE = 'edx.{0}core'.format(QUEUE_VARIANT)
HIGH_PRIORITY_QUEUE = f'edx.{QUEUE_VARIANT}core.high'
DEFAULT_PRIORITY_QUEUE = f'edx.{QUEUE_VARIANT}core.default'
HIGH_MEM_QUEUE = f'edx.{QUEUE_VARIANT}core.high_mem'
HIGH_PRIORITY_QUEUE = 'edx.{0}core.high'.format(QUEUE_VARIANT)
DEFAULT_PRIORITY_QUEUE = 'edx.{0}core.default'.format(QUEUE_VARIANT)
HIGH_MEM_QUEUE = 'edx.{0}core.high_mem'.format(QUEUE_VARIANT)
CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
CELERY_DEFAULT_ROUTING_KEY = DEFAULT_PRIORITY_QUEUE
@@ -358,7 +360,7 @@ if "TRACKING_IGNORE_URL_PATTERNS" in ENV_TOKENS:
SSL_AUTH_EMAIL_DOMAIN = ENV_TOKENS.get("SSL_AUTH_EMAIL_DOMAIN", "MIT.EDU")
SSL_AUTH_DN_FORMAT_STRING = ENV_TOKENS.get(
"SSL_AUTH_DN_FORMAT_STRING",
"/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}"
u"/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}"
)
# Video Caching. Pairing country codes with CDN URLs.
@@ -532,11 +534,11 @@ CELERY_BROKER_VHOST = ENV_TOKENS.get("CELERY_BROKER_VHOST", "")
CELERY_BROKER_USER = AUTH_TOKENS.get("CELERY_BROKER_USER", "")
CELERY_BROKER_PASSWORD = AUTH_TOKENS.get("CELERY_BROKER_PASSWORD", "")
BROKER_URL = "{}://{}:{}@{}/{}".format(CELERY_BROKER_TRANSPORT,
CELERY_BROKER_USER,
CELERY_BROKER_PASSWORD,
CELERY_BROKER_HOSTNAME,
CELERY_BROKER_VHOST)
BROKER_URL = "{0}://{1}:{2}@{3}/{4}".format(CELERY_BROKER_TRANSPORT,
CELERY_BROKER_USER,
CELERY_BROKER_PASSWORD,
CELERY_BROKER_HOSTNAME,
CELERY_BROKER_VHOST)
BROKER_USE_SSL = ENV_TOKENS.get('CELERY_BROKER_USE_SSL', False)
BROKER_TRANSPORT_OPTIONS = {

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
This config file runs the simplest dev environment using sqlite, and db-based
sessions. Assumes structure:
@@ -17,15 +18,15 @@ import logging
import os
from collections import OrderedDict
from random import choice # lint-amnesty, pylint: disable=unused-import
from string import ascii_letters, digits, punctuation # lint-amnesty, pylint: disable=unused-import
from string import digits, ascii_letters, punctuation # lint-amnesty, pylint: disable=unused-import
from uuid import uuid4
import openid.oidutil
from django.utils.translation import ugettext_lazy
from edx_django_utils.plugins import add_plugins
from path import Path as path
from six.moves import range # lint-amnesty, pylint: disable=unused-import
from common.djangoapps.util.testing import patch_sessions, patch_testcase # pylint: disable=wrong-import-order
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType
from openedx.core.lib.derived import derive_settings
from openedx.core.lib.tempdir import mkdtemp_clean
@@ -33,6 +34,8 @@ from xmodule.modulestore.modulestore_settings import update_module_store_setting
from .common import *
from common.djangoapps.util.testing import patch_sessions, patch_testcase # pylint: disable=wrong-import-order
# This patch disables the commit_on_success decorator during tests
# in TestCase subclasses.
patch_testcase()
@@ -127,7 +130,7 @@ COMMENTS_SERVICE_URL = 'http://localhost:4567'
DJFS = {
'type': 'osfs',
'directory_root': f'{DATA_DIR}/django-pyfs/static/django-pyfs',
'directory_root': '{}/django-pyfs/static/django-pyfs'.format(DATA_DIR),
'url_root': '/static/django-pyfs',
}
@@ -165,7 +168,7 @@ update_module_store_settings(
doc_store_settings={
'host': MONGO_HOST,
'port': MONGO_PORT_NUM,
'db': f'test_xmodule_{THIS_UUID}',
'db': 'test_xmodule_{}'.format(THIS_UUID),
'collection': 'test_modulestore',
},
)
@@ -174,7 +177,7 @@ CONTENTSTORE = {
'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
'DOC_STORE_CONFIG': {
'host': MONGO_HOST,
'db': f'test_xcontent_{THIS_UUID}',
'db': 'test_xcontent_{}'.format(THIS_UUID),
'port': MONGO_PORT_NUM,
}
}
@@ -381,8 +384,8 @@ openid.oidutil.log = lambda message, level=0: None
# Include a non-ascii character in PLATFORM_NAME and PLATFORM_DESCRIPTION to uncover possible
# UnicodeEncodeErrors in tests. Also use lazy text to reveal possible json dumps errors
PLATFORM_NAME = ugettext_lazy("édX")
PLATFORM_DESCRIPTION = ugettext_lazy("Open édX Platform")
PLATFORM_NAME = ugettext_lazy(u"édX")
PLATFORM_DESCRIPTION = ugettext_lazy(u"Open édX Platform")
SITE_NAME = "edx.org"
@@ -475,7 +478,7 @@ COURSE_BLOCKS_API_EXTRA_FIELDS = [
]
COURSE_CATALOG_URL_ROOT = 'https://catalog.example.com'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"]
COMPREHENSIVE_THEME_LOCALE_PATHS = [REPO_ROOT / "themes/conf/locale", ]

View File

@@ -7,10 +7,10 @@ This file contains implementation override of SearchFilterGenerator which will a
import six
from search.filter_generator import SearchFilterGenerator
from common.djangoapps.student.models import CourseEnrollment
from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartitionScheme
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from common.djangoapps.student.models import CourseEnrollment
INCLUDE_SCHEMES = [CohortPartitionScheme, RandomUserPartitionScheme, ]
SCHEME_SUPPORTS_ASSIGNMENT = [RandomUserPartitionScheme, ]
@@ -29,12 +29,12 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
def field_dictionary(self, **kwargs):
""" add course if provided otherwise add courses in which the user is enrolled in """
field_dictionary = super().field_dictionary(**kwargs)
field_dictionary = super(LmsSearchFilterGenerator, self).field_dictionary(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
if not kwargs.get('user'):
field_dictionary['course'] = []
elif not kwargs.get('course_id'):
user_enrollments = self._enrollments_for_user(kwargs['user'])
field_dictionary['course'] = [str(enrollment.course_id) for enrollment in user_enrollments]
field_dictionary['course'] = [six.text_type(enrollment.course_id) for enrollment in user_enrollments]
# if we have an org filter, only include results for this org filter
course_org_filter = configuration_helpers.get_current_site_orgs()
@@ -47,7 +47,7 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
"""
Exclude any courses defined outside the current org.
"""
exclude_dictionary = super().exclude_dictionary(**kwargs)
exclude_dictionary = super(LmsSearchFilterGenerator, self).exclude_dictionary(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
course_org_filter = configuration_helpers.get_current_site_orgs()
# If we have a course filter we are ensuring that we only get those courses above
if not course_org_filter:

View File

@@ -3,13 +3,12 @@ Tests for the lms_filter_generator
"""
from unittest.mock import Mock, patch
import six
from mock import Mock, patch
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import UserFactory
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@@ -53,7 +52,7 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
)
def setUp(self):
super().setUp()
super(LmsSearchFilterGeneratorTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_courses()
self.user = UserFactory.create(username="jack", email="jack@fake.edx.org", password='test')
@@ -67,8 +66,8 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
assert 'start_date' in filter_dictionary
assert str(self.courses[0].id) in field_dictionary['course']
assert str(self.courses[1].id) in field_dictionary['course']
assert six.text_type(self.courses[0].id) in field_dictionary['course']
assert six.text_type(self.courses[1].id) in field_dictionary['course']
def test_course_id_provided(self):
"""
@@ -76,11 +75,11 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
"""
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=str(self.courses[0].id)
course_id=six.text_type(self.courses[0].id)
)
assert 'start_date' in filter_dictionary
assert str(self.courses[0].id) == field_dictionary['course']
assert six.text_type(self.courses[0].id) == field_dictionary['course']
def test_user_not_provided(self):
"""

View File

@@ -3,6 +3,7 @@ Tests for the lms_result_processor
"""
import six
import pytest
from lms.djangoapps.courseware.tests.factories import UserFactory
@@ -63,7 +64,7 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
)
def setUp(self):
super().setUp()
super(LmsSearchResultProcessorTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def test_url_parameter(self):
@@ -75,15 +76,15 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
srp = LmsSearchResultProcessor(
{
"course": str(self.course.id),
"id": str(self.html.scope_ids.usage_id),
"course": six.text_type(self.course.id),
"id": six.text_type(self.html.scope_ids.usage_id),
"content": {"text": "This is the html text"}
},
"test"
)
assert srp.url == '/courses/{}/jump_to/{}'.format(str(self.course.id),
str(self.html.scope_ids.usage_id))
assert srp.url == '/courses/{}/jump_to/{}'.format(six.text_type(self.course.id),
six.text_type(self.html.scope_ids.usage_id))
def test_should_remove(self):
"""
@@ -91,8 +92,8 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
"""
srp = LmsSearchResultProcessor(
{
"course": str(self.course.id),
"id": str(self.html.scope_ids.usage_id),
"course": six.text_type(self.course.id),
"id": six.text_type(self.html.scope_ids.usage_id),
"content": {"text": "This is html test text"}
},
"test"

View File

@@ -18,7 +18,7 @@ class LmsUtilsTest(ModuleStoreTestCase):
"""
Setup a dummy course content.
"""
super().setUp()
super(LmsUtilsTest, self).setUp()
with self.store.default_store(ModuleStoreEnum.Type.mongo):
self.course = CourseFactory.create()

View File

@@ -70,7 +70,7 @@ class XBlockValidationTest(LmsXBlockMixinTestCase):
Unit tests for XBlock validation
"""
def setUp(self):
super().setUp()
super(XBlockValidationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def verify_validation_message(self, message, expected_message, expected_message_type):
@@ -280,7 +280,7 @@ class OpenAssessmentBlockMixinTestCase(ModuleStoreTestCase):
"""
def setUp(self):
super().setUp()
super(OpenAssessmentBlockMixinTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
self.section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section')
self.open_assessment = ItemFactory.create(
@@ -378,7 +378,7 @@ def ddt_named(parent, child):
Helper to get more readable dynamically-generated test names from ddt.
"""
args = RenamedTuple([parent, child])
args.__name__ = f'parent_{parent}_child_{child}' # pylint: disable=attribute-defined-outside-init
args.__name__ = 'parent_{}_child_{}'.format(parent, child) # pylint: disable=attribute-defined-outside-init
return args
@@ -406,7 +406,7 @@ class XBlockMergedGroupAccessTest(LmsXBlockMixinTestCase):
)
def setUp(self):
super().setUp()
super(XBlockMergedGroupAccessTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def verify_group_access(self, block_location, expected_dict):

View File

@@ -4,6 +4,7 @@
import logging
import mimetypes
from django.conf import settings # lint-amnesty, pylint: disable=unused-import
from django.test import TestCase
log = logging.getLogger(__name__)

View File

@@ -14,9 +14,8 @@ from edx_api_doc_tools import make_docs_urls
from edx_django_utils.plugins import get_plugin_url_patterns
from ratelimitbackend import admin
from common.djangoapps.student import views as student_views
from common.djangoapps.util import views as util_views
from lms.djangoapps.branding import views as branding_views
from lms.djangoapps.debug import views as debug_views
from lms.djangoapps.certificates import views as certificates_views
from lms.djangoapps.courseware.masquerade import MasqueradeView
from lms.djangoapps.courseware.module_render import (
@@ -28,14 +27,13 @@ from lms.djangoapps.courseware.module_render import (
from lms.djangoapps.courseware.views import views as courseware_views
from lms.djangoapps.courseware.views.index import CoursewareIndex
from lms.djangoapps.courseware.views.views import CourseTabView, EnrollStaffView, StaticCourseTabView
from lms.djangoapps.debug import views as debug_views
from lms.djangoapps.discussion import views as discussion_views
from lms.djangoapps.discussion.config.settings import is_forum_daily_digest_enabled
from lms.djangoapps.discussion.notification_prefs import views as notification_prefs_views
from lms.djangoapps.instructor.views import instructor_dashboard as instructor_dashboard_views
from lms.djangoapps.instructor_task import views as instructor_task_views
from lms.djangoapps.static_template_view import views as static_template_view_views
from lms.djangoapps.staticbook import views as staticbook_views
from lms.djangoapps.static_template_view import views as static_template_view_views
from openedx.core.apidocs import api_info
from openedx.core.djangoapps.auth_exchange.views import LoginWithAccessTokenView
from openedx.core.djangoapps.catalog.models import CatalogIntegration
@@ -54,6 +52,8 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from openedx.core.djangoapps.user_authn.views.login import redirect_to_lms_login
from openedx.core.djangoapps.verified_track_content import views as verified_track_content_views
from openedx.features.enterprise_support.api import enterprise_enabled
from common.djangoapps.student import views as student_views
from common.djangoapps.util import views as util_views
RESET_COURSE_DEADLINES_NAME = 'reset_course_deadlines'
RENDER_XBLOCK_NAME = 'render_xblock'
@@ -256,9 +256,9 @@ if settings.WIKI_ENABLED:
# These urls are for viewing the wiki in the context of a course. They should
# never be returned by a reverse() so they come after the other url patterns
url(fr'^courses/{settings.COURSE_ID_PATTERN}/course_wiki/?$',
url(r'^courses/{}/course_wiki/?$'.format(settings.COURSE_ID_PATTERN),
course_wiki_views.course_wiki_redirect, name='course_wiki'),
url(fr'^courses/{settings.COURSE_KEY_REGEX}/wiki/',
url(r'^courses/{}/wiki/'.format(settings.COURSE_KEY_REGEX),
include((wiki_url_patterns, 'course_wiki_do_not_reverse'), namespace='course_wiki_do_not_reverse')),
]
@@ -314,7 +314,7 @@ urlpatterns += [
# passed as a 'view' parameter to the URL.
# Note: This is not an API. Compare this with the xblock_view API above.
url(
fr'^xblock/{settings.USAGE_KEY_PATTERN}$',
r'^xblock/{usage_key_string}$'.format(usage_key_string=settings.USAGE_KEY_PATTERN),
courseware_views.render_xblock,
name=RENDER_XBLOCK_NAME,
),
@@ -664,7 +664,7 @@ urlpatterns += [
# Calendar Sync UI in LMS
url(
fr'^courses/{settings.COURSE_ID_PATTERN}/',
r'^courses/{}/'.format(settings.COURSE_ID_PATTERN,),
include('openedx.features.calendar_sync.urls'),
),
@@ -912,7 +912,7 @@ urlpatterns += [
# Custom courses on edX (CCX) URLs
if settings.FEATURES.get('CUSTOM_COURSES_EDX'):
urlpatterns += [
url(fr'^courses/{settings.COURSE_ID_PATTERN}/',
url(r'^courses/{}/'.format(settings.COURSE_ID_PATTERN),
include('lms.djangoapps.ccx.urls')),
url(r'^api/ccx/', include(('lms.djangoapps.ccx.api.urls', 'lms.djangoapps.ccx'), namespace='ccx_api')),
]

View File

@@ -8,32 +8,28 @@ It exposes a module-level variable named ``application``. Django's
``WSGI_APPLICATION`` setting.
"""
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
# Patch the xml libs
from safe_lxml import defuse_xml_libs
defuse_xml_libs()
# Disable PyContract contract checking when running as a webserver
import contracts # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import \
get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
# Patch the xml libs
from safe_lxml import defuse_xml_libs
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-position
defuse_xml_libs()
contracts.disable_all()
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-position
# Trigger a forced initialization of our modulestores since this can take a
# while to complete and we want this done before HTTP requests are accepted.
modulestore()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
application = get_wsgi_application()

View File

@@ -5,23 +5,19 @@ This module contains the WSGI application used for Apache deployment.
It exposes a module-level variable named ``application``.
"""
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import \
get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
# Patch the xml libs before anything else.
from safe_lxml import defuse_xml_libs
defuse_xml_libs()
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
os.environ.setdefault("SERVICE_VARIANT", "lms")
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
application = get_wsgi_application() # pylint: disable=invalid-name