From 36327ff27c1462c6c3f5251e21ca4c06f1cac87c Mon Sep 17 00:00:00 2001 From: Taylor Payne Date: Wed, 2 Jul 2025 12:09:39 -0600 Subject: [PATCH] refactor: import constants into platform-wide settings module --- cms/envs/common.py | 1 - lms/envs/common.py | 1 - openedx/core/constants.py | 5 +++++ openedx/envs/common.py | 6 ------ 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 9931779221..bb9c26029b 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -50,7 +50,6 @@ from django.utils.translation import gettext_lazy as _ import lms.envs.common -from openedx.core.constants import COURSE_KEY_REGEX, COURSE_KEY_PATTERN, COURSE_ID_PATTERN from openedx.envs.common import * # pylint: disable=wildcard-import from lms.envs.common import ( diff --git a/lms/envs/common.py b/lms/envs/common.py index eac73997e6..d635ac23e4 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -64,7 +64,6 @@ from enterprise.constants import ( DEFAULT_ENTERPRISE_ENROLLMENT_INTENTIONS_ROLE, ) -from openedx.core.constants import COURSE_KEY_REGEX, COURSE_KEY_PATTERN, COURSE_ID_PATTERN from openedx.core.lib.derived import Derived from openedx.core.release import doc_version from openedx.envs.common import * # pylint: disable=wildcard-import diff --git a/openedx/core/constants.py b/openedx/core/constants.py index ad16e9e595..e6a99b2c1e 100644 --- a/openedx/core/constants.py +++ b/openedx/core/constants.py @@ -12,3 +12,8 @@ COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id') COURSE_KEY_REGEX = COURSE_KEY_PATTERN.replace('P', ':') COURSE_PUBLISHED = 'published' COURSE_UNPUBLISHED = 'unpublished' + +ASSET_KEY_PATTERN = r'(?P(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' + +USAGE_KEY_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' +USAGE_ID_PATTERN = USAGE_KEY_PATTERN.replace('usage_key_string', 'usage_id') diff --git a/openedx/envs/common.py b/openedx/envs/common.py index 15fc835f1c..ceccce3342 100644 --- a/openedx/envs/common.py +++ b/openedx/envs/common.py @@ -780,9 +780,3 @@ GENERATE_PROFILE_SCORES = False # in the AccountCreationForm and the user_api through the ENABLE_UNICODE_USERNAME feature flag. USERNAME_REGEX_PARTIAL = r'[\w .@_+-]+' USERNAME_PATTERN = fr'(?P{USERNAME_REGEX_PARTIAL})' - -# These are standard regexes for pulling out info like course_ids, usage_ids, etc. -# They are used so that URLs with deprecated-format strings still work. -USAGE_KEY_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' -ASSET_KEY_PATTERN = r'(?P(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' -USAGE_ID_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'