feat: wrap new course_not_started_enterprise_learner in a SettingToggle
ENT-8078
This commit is contained in:
@@ -9,6 +9,7 @@ from logging import getLogger
|
||||
|
||||
from crum import get_current_request
|
||||
from django.conf import settings
|
||||
from edx_toggles.toggles import SettingToggle
|
||||
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomerUser
|
||||
from pytz import UTC
|
||||
|
||||
@@ -137,9 +138,10 @@ def check_start_date(user, days_early_for_beta, start, course_key, display_error
|
||||
|
||||
# Before returning a StartDateError, determine if the learner should be redirected to the enterprise learner
|
||||
# portal by returning StartDateEnterpriseLearnerError instead.
|
||||
request = get_current_request()
|
||||
if request and enterprise_learner_enrolled(request, user, course_key):
|
||||
return StartDateEnterpriseLearnerError(start, display_error_to_user=display_error_to_user)
|
||||
if SettingToggle('COURSEWARE_COURSE_NOT_STARTED_ENTERPRISE_LEARNER_ERROR', default=False).is_enabled():
|
||||
request = get_current_request()
|
||||
if request and enterprise_learner_enrolled(request, user, course_key):
|
||||
return StartDateEnterpriseLearnerError(start, display_error_to_user=display_error_to_user)
|
||||
|
||||
return StartDateError(start, display_error_to_user=display_error_to_user)
|
||||
|
||||
|
||||
@@ -903,6 +903,7 @@ class CourseOverviewAccessTestCase(ModuleStoreTestCase):
|
||||
)
|
||||
@ddt.unpack
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False, 'ENABLE_ENTERPRISE_INTEGRATION': True})
|
||||
@override_settings(COURSEWARE_COURSE_NOT_STARTED_ENTERPRISE_LEARNER_ERROR=True)
|
||||
def test_course_catalog_access_num_queries_enterprise(self, user_attr_name, course_attr_name):
|
||||
"""
|
||||
Similar to test_course_catalog_access_num_queries_no_enterprise, except enable enterprise features and make the
|
||||
|
||||
@@ -3257,6 +3257,7 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
|
||||
)
|
||||
@ddt.unpack
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False, 'ENABLE_ENTERPRISE_INTEGRATION': True})
|
||||
@override_settings(COURSEWARE_COURSE_NOT_STARTED_ENTERPRISE_LEARNER_ERROR=True)
|
||||
def test_is_course_open_for_learner(
|
||||
self,
|
||||
start_date_modifier,
|
||||
|
||||
@@ -4677,6 +4677,19 @@ DATA_CONSENT_SHARE_CACHE_TIMEOUT = 8 * 60 * 60 # 8 hours
|
||||
ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
|
||||
ENTERPRISE_TAGLINE = ''
|
||||
|
||||
# .. toggle_name: COURSEWARE_COURSE_NOT_STARTED_ENTERPRISE_LEARNER_ERROR
|
||||
# .. toggle_implementation: SettingToggle
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: If disabled (False), this switch causes the CourseTabView API (or whatever else calls
|
||||
# check_course_open_for_learner()) to always return the legacy `course_not_started` error code in ALL cases where the
|
||||
# course has not started. If enabled (True), the API will respond with `course_not_started_enterprise_learner` in a
|
||||
# subset of cases where the learner is enrolled via subsidy, and `course_not_started` in all other cases.
|
||||
# .. toggle_use_cases: temporary
|
||||
# .. toggle_creation_date: 2023-12-18
|
||||
# .. toggle_target_removal_date: 2023-12-19
|
||||
# .. toggle_tickets: ENT-8078
|
||||
COURSEWARE_COURSE_NOT_STARTED_ENTERPRISE_LEARNER_ERROR = False
|
||||
|
||||
############## Settings for Course Enrollment Modes ######################
|
||||
# The min_price key refers to the minimum price allowed for an instance
|
||||
# of a particular type of course enrollment mode. This is not to be confused
|
||||
|
||||
Reference in New Issue
Block a user