Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Command(BaseCommand):
In Lilac and beyond, the edx-organizations models are enabled globally.
This command exists to migrate pre-Lilac instances that did not enable
`FEATURES['ORGANIZATIONS_APP']`.
the ``ORGANIZATIONS_APP`` feature flag.
It automatically creates all missing Organization and OrganizationCourse
instances based on the course runs in the system (loaded from CourseOverview)
and the V1 content libraries in the system (loaded from the Modulestore).
Expand Down
6 changes: 3 additions & 3 deletions common/djangoapps/student/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ def is_feature_enabled(cls):
"""
Returns whether the feature flag around this functionality has been set
"""
return settings.FEATURES['ENABLE_MAX_FAILED_LOGIN_ATTEMPTS']
return settings.ENABLE_MAX_FAILED_LOGIN_ATTEMPTS

@classmethod
def is_user_locked_out(cls, user):
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def log_successful_login(sender, request, user, **kwargs): # pylint: disable=un
'event_type': "login",
}
)
if settings.FEATURES['SQUELCH_PII_IN_LOGS']:
if settings.SQUELCH_PII_IN_LOGS:
AUDIT_LOG.info(f"Login success - user.id: {user.id}")
else:
AUDIT_LOG.info(f"Login success - {user.username} ({user.email})")
Expand All @@ -1330,7 +1330,7 @@ def log_successful_logout(sender, request, user, **kwargs): # pylint: disable=u
'event_type': "logout",
}
)
if settings.FEATURES['SQUELCH_PII_IN_LOGS']:
if settings.SQUELCH_PII_IN_LOGS:
AUDIT_LOG.info(f'Logout - user.id: {request.user.id}') # pylint: disable=logging-format-interpolation
else:
AUDIT_LOG.info(f'Logout - {request.user}') # pylint: disable=logging-format-interpolation
Expand Down
6 changes: 3 additions & 3 deletions common/djangoapps/student/tests/test_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def test_unicode_username(self):
assert str(LoginFailures.objects.get(user=self.user)) == f'§: 10 - {self.user_lockout_until.isoformat()}'
assert str(LoginFailures.objects.get(user=self.user2)) == 'Zażółć gęślą jaźń: 2 - -'

@override_settings(FEATURES={'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True})
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True)
def test_feature_enabled(self):
url = reverse('admin:student_loginfailures_changelist')
response = self.client.get(url)
Expand All @@ -372,7 +372,7 @@ def test_feature_disabled(self, url):
response = self.client.post(url)
assert response.status_code == 403

@override_settings(FEATURES={'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True})
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True)
def test_unlock_student_accounts(self):
"""Test batch unlock student accounts."""
url = reverse('admin:student_loginfailures_changelist')
Expand All @@ -387,7 +387,7 @@ def test_unlock_student_accounts(self):
count = LoginFailures.objects.count()
assert count == 0

@override_settings(FEATURES={'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True})
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True)
def test_unlock_account(self):
"""Test unlock single student account."""
url = reverse('admin:student_loginfailures_change', args=(1, ))
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/course_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _filter_by_search(course_queryset, search_term, mobile_search=False):
"""
Filters a course queryset by the specified search term.
"""
if not settings.FEATURES['ENABLE_COURSEWARE_SEARCH'] or not search_term:
if not settings.ENABLE_COURSEWARE_SEARCH or not search_term:
return course_queryset

# Return all the results, 10K is the maximum allowed value for ElasticSearch.
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,8 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
},
)
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False, 'ENABLE_ENTERPRISE_INTEGRATION': True})
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
def test_is_course_open_for_learner(
self,
start_date_modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def enroll_user(self, user, course, create_grade=False):
@patch('common.djangoapps.student.models.course_enrollment.segment.track')
@patch('lms.djangoapps.program_enrollments.management.commands.send_program_course_nudge_email.get_programs')
@patch('lms.djangoapps.certificates.api.certificates_viewable_for_course', return_value=True)
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
def test_email_send(self, add_no_commit, __, get_programs_mock, mock_track): # noqa: PT019
"""
Test Segment fired as expected.
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_email_send(self, add_no_commit, __, get_programs_mock, mock_track): #
)
@patch('common.djangoapps.student.models.course_enrollment.segment.track')
@patch('lms.djangoapps.program_enrollments.management.commands.send_program_course_nudge_email.get_programs')
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
def test_email_no_course_recommendation(self, add_no_commit, get_programs_mock, mock_track):
"""
Test Segment fired as expected.
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/support/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def test_order_source_system_information(self):
assert len(data) == 1
assert data[0]['source_system'] == 'commercetools'

@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@enterprise_is_enabled()
def test_get_enrollments_enterprise_enabled(self):
url = reverse(
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/enrollments/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def test_enrollment_with_global_staff_permissions(self, using_global_staff_user,

@httpretty.activate
@override_settings(ENTERPRISE_SERVICE_WORKER_USERNAME='enterprise_worker',
FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
ENABLE_ENTERPRISE_INTEGRATION=True)
@patch('openedx.features.enterprise_support.api.enterprise_customer_from_api')
def test_enterprise_course_enrollment_with_ec_uuid(self, mock_enterprise_customer_from_api):
"""Verify that the enrollment completes when the EnterpriseCourseEnrollment creation succeeds. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def setUp(self):
)

@with_site_configuration(configuration={"COURSE_CATALOG_API_URL": "foo"})
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@enterprise_is_enabled()
def test_program_list_enterprise(self):
"""
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_program_list_enterprise(self):
}

@with_site_configuration(configuration={"COURSE_CATALOG_API_URL": "foo"})
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@enterprise_is_enabled()
def test_program_empty_list_if_no_enterprise_enrollments(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/user_authn/views/login_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def login_and_registration_form(request, initial_mode="login"):
'combined_login_and_register': True,
'disable_footer': not configuration_helpers.get_value(
'ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER',
settings.FEATURES['ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER']
getattr(settings, 'ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER', False)
),
}

Expand Down
10 changes: 5 additions & 5 deletions openedx/core/djangoapps/user_authn/views/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def test_enterprise_in_url(
self._assert_response(response, success=True)
self._assert_redirect_url(response, settings.LMS_ROOT_URL + expected_redirect + next_url)

@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
@override_settings(SQUELCH_PII_IN_LOGS=True)
def test_login_success_no_pii(self):
response, mock_audit_log = self._login_response(
self.user_email, self.password, patched_audit_log='common.djangoapps.student.models.user.AUDIT_LOG'
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_login_fail_no_user_exists(self):
)
self._assert_audit_log(mock_audit_log, 'warning', ['Login failed', 'Unknown user email', email_hash])

@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
@override_settings(SQUELCH_PII_IN_LOGS=True)
def test_login_fail_no_user_exists_no_pii(self):
nonexistent_email = 'not_a_user@edx.org'
response, mock_audit_log = self._login_response(
Expand All @@ -364,7 +364,7 @@ def test_login_fail_wrong_password(self):
self._assert_audit_log(mock_audit_log, 'warning',
['Login failed', 'password for', str(self.user.id), 'invalid'])

@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
@override_settings(SQUELCH_PII_IN_LOGS=True)
def test_login_fail_wrong_password_no_pii(self):
response, mock_audit_log = self._login_response(self.user_email, 'wrong_password')
self._assert_response(response, success=False, value=self.LOGIN_FAILED_WARNING)
Expand Down Expand Up @@ -534,7 +534,7 @@ def test_unicode_mktg_cookie_names(self):
}
assert_dict_contains_subset(self, expected, response.context_data)

@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
@override_settings(SQUELCH_PII_IN_LOGS=True)
def test_logout_logging_no_pii(self):
response, _ = self._login_response(self.user_email, self.password)
self._assert_response(response, success=True)
Expand Down Expand Up @@ -795,7 +795,7 @@ def test_check_password_policy_compliance(self):
response_content = json.loads(response.content.decode('utf-8'))
assert response_content.get('success')

@patch.dict(settings.FEATURES, {"ENABLE_MAX_FAILED_LOGIN_ATTEMPTS": True})
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True)
@override_settings(PASSWORD_POLICY_COMPLIANCE_ROLLOUT_CONFIG={'ENFORCE_COMPLIANCE_ON_LOGIN': True})
def test_check_password_policy_compliance_exception(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def test_reset_password_with_other_user_link(self):
self.assertRaises(Http404, PasswordResetConfirmWrapper.as_view(), reset_request, uidb36=self.uidb36, # noqa: PT027 # pylint: disable=line-too-long
token=self.token)

@override_settings(FEATURES={'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True}, MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED=1)
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True, MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED=1)
def test_password_reset_with_login_failures_feature_enabled(self):
"""
Tests that user's login failures lockout counter is reset upon successful password reset.
Expand Down Expand Up @@ -1013,7 +1013,7 @@ def test_password_reset_api_throttle(self):
response = self.client.post(path, request_param)
assert response.status_code == 429

@override_settings(FEATURES={'ENABLE_MAX_FAILED_LOGIN_ATTEMPTS': True}, MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED=1)
@override_settings(ENABLE_MAX_FAILED_LOGIN_ATTEMPTS=True, MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED=1)
def test_password_reset_request_with_login_failures_feature_enabled(self):
"""
Tests that user's login failures lockout counter is reset upon successful password reset.
Expand Down
2 changes: 1 addition & 1 deletion openedx/features/enterprise_support/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def enterprise_enabled():
"""
Determines whether the Enterprise app is installed
"""
return django_apps.is_installed('enterprise') and settings.FEATURES.get('ENABLE_ENTERPRISE_INTEGRATION', False)
return django_apps.is_installed('enterprise') and getattr(settings, 'ENABLE_ENTERPRISE_INTEGRATION', False)


def enterprise_is_enabled(otherwise=None):
Expand Down
5 changes: 0 additions & 5 deletions openedx/features/enterprise_support/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
"""


from django.conf import settings

FEATURES_WITH_ENTERPRISE_ENABLED = settings.FEATURES.copy()
FEATURES_WITH_ENTERPRISE_ENABLED['ENABLE_ENTERPRISE_INTEGRATION'] = True

FAKE_ENTERPRISE_CUSTOMER = {
'active': True,
'branding_configuration': None,
Expand Down
5 changes: 2 additions & 3 deletions openedx/features/enterprise_support/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
get_enterprise_learner_data_from_db,
get_enterprise_learner_portal_enabled_message,
)
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
from openedx.features.enterprise_support.tests.factories import (
EnterpriseCourseEnrollmentFactory,
EnterpriseCustomerIdentityProviderFactory,
Expand All @@ -59,7 +58,7 @@ def __repr__(self):


@ddt.ddt
@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@skip_unless_lms
class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
"""
Expand Down Expand Up @@ -579,7 +578,7 @@ def test_get_dashboard_consent_notification(
else:
assert notification_string == ''

@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=False))
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=False)
def test_utils_with_enterprise_disabled(self):
"""
Test that disabling the enterprise integration flag causes
Expand Down
3 changes: 1 addition & 2 deletions openedx/features/enterprise_support/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.features.enterprise_support.context import get_enterprise_event_context
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
from openedx.features.enterprise_support.tests.factories import (
EnterpriseCourseEnrollmentFactory,
EnterpriseCustomerUserFactory,
)
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin


@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@skip_unless_lms
class TestEnterpriseContext(EnterpriseServiceMockMixin, CacheIsolationTestCase):
"""
Expand Down
3 changes: 1 addition & 2 deletions openedx/features/enterprise_support/tests/test_logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
from openedx.features.enterprise_support.api import enterprise_enabled
from openedx.features.enterprise_support.tests import (
FAKE_ENTERPRISE_CUSTOMER,
FEATURES_WITH_ENTERPRISE_ENABLED,
factories,
)
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin


@ddt.ddt
@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@skip_unless_lms
class EnterpriseLogoutTests(EnterpriseServiceMockMixin, CacheIsolationTestCase, UrlResetMixin):
""" Tests for the enterprise logout functionality. """
Expand Down
3 changes: 1 addition & 2 deletions openedx/features/enterprise_support/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from openedx.core.djangoapps.commerce.utils import ECOMMERCE_DATE_FORMAT
from openedx.core.djangoapps.credit.tests.test_api import TEST_ECOMMERCE_WORKER
from openedx.core.djangoapps.signals.signals import COURSE_ASSESSMENT_GRADE_CHANGED, COURSE_GRADE_NOW_PASSED
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
from openedx.features.enterprise_support.tests.factories import (
EnterpriseCourseEnrollmentFactory,
EnterpriseCustomerFactory,
Expand All @@ -42,7 +41,7 @@


@ddt.ddt
@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@override_settings(ECOMMERCE_SERVICE_WORKER_USERNAME=TEST_ECOMMERCE_WORKER)
class EnterpriseSupportSignals(SharedModuleStoreTestCase):
"""
Expand Down
5 changes: 2 additions & 3 deletions openedx/features/enterprise_support/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import UserFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
from openedx.features.enterprise_support.tests.factories import (
EnterpriseCustomerBrandingConfigurationFactory,
EnterpriseCustomerFactory,
Expand Down Expand Up @@ -59,7 +58,7 @@


@ddt.ddt
@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@skip_unless_lms
class TestEnterpriseUtils(TestCase):
"""
Expand Down Expand Up @@ -594,7 +593,7 @@ def test_user_has_social_auth_record_no_enterprise_customer(self, mock_tpa, mock
assert not mock_user_social_auth.objects.select_related.called


@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True)
@skip_unless_lms
class TestCourseAccessed(SharedModuleStoreTestCase, CompletionWaffleTestMixin):
"""
Expand Down
2 changes: 1 addition & 1 deletion xmodule/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def student_view_data(self, context=None): # pylint: disable=unused-argument
"""
Return a JSON representation of the student_view of this XBlock.
"""
if getattr(settings, 'FEATURES', {}).get(self.ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA, False):
if getattr(settings, self.ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA, False):
return {'enabled': True, 'html': self.get_html()}
else:
return {
Expand Down
5 changes: 2 additions & 3 deletions xmodule/tests/test_html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def setUpClass(cls):

@ddt.data(
{},
dict(FEATURES={}),
dict(FEATURES=dict(ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA=False))
dict(ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA=False),
)
def test_disabled(self, settings):
"""
Expand All @@ -58,7 +57,7 @@ def test_disabled(self, settings):
'<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">', # Images allowed
'short string ' * 100, # May contain long strings
)
@override_settings(FEATURES=dict(ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA=True))
@override_settings(ENABLE_HTML_XBLOCK_STUDENT_VIEW_DATA=True)
def test_common_values(self, html):
"""
Ensure that student_view_data will return HTML data when enabled,
Expand Down
Loading