Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ def _get_course_index_context(request, course_key, course_block):
frontend_app_publisher_url = configuration_helpers.get_value_for_org(
course_block.location.org,
'FRONTEND_APP_PUBLISHER_URL',
settings.FEATURES.get('FRONTEND_APP_PUBLISHER_URL', False)
settings.FRONTEND_APP_PUBLISHER_URL
)
# gather any errors in the currently stored proctoring settings.
advanced_dict = CourseMetadata.fetch(course_block)
Expand Down
7 changes: 7 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ def make_lms_template_path(settings):
FRONTEND_LOGOUT_URL = '/logout/'
FRONTEND_REGISTER_URL = Derived(lambda settings: settings.LMS_ROOT_URL + '/register')

# .. setting_name: FRONTEND_APP_PUBLISHER_URL
# .. setting_default: None
# .. setting_description: Base URL of the publisher frontend app. When set (globally here or per-org via
# site configuration), the course "settings" page in Studio links out to the publisher app. Left unset
# (None) by default, in which case no publisher link is shown.
FRONTEND_APP_PUBLISHER_URL = None

ENTERPRISE_API_URL = Derived(lambda settings: settings.LMS_INTERNAL_ROOT_URL + '/enterprise/api/v1/')
ENTERPRISE_CONSENT_API_URL = Derived(lambda settings: settings.LMS_INTERNAL_ROOT_URL + '/consent/api/v1/')

Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@

@ddt.ddt
@skip_unless_lms
@override_settings(MODE_CREATION_FOR_TESTING=True)
class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTestCase, CourseCatalogServiceMockMixin):
"""
Course Mode View tests
"""
URLCONF_MODULES = ['common.djangoapps.course_modes.urls']

@patch.dict(settings.FEATURES, {'MODE_CREATION_FOR_TESTING': True})
def setUp(self):
super().setUp()
now = datetime.now(ZoneInfo("UTC"))
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]

# Enable verified mode creation
if settings.FEATURES.get('MODE_CREATION_FOR_TESTING'):
if getattr(settings, 'MODE_CREATION_FOR_TESTING', False):
urlpatterns.append(
re_path(fr'^create_mode/{settings.COURSE_ID_PATTERN}/$',
views.create_mode,
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def _redirect_to_course_or_dashboard(self, course, course_key, user):
def create_mode(request, course_id):
"""Add a mode to the course corresponding to the given course ID.

Only available when settings.FEATURES['MODE_CREATION_FOR_TESTING'] is True.
Only available when settings.MODE_CREATION_FOR_TESTING is True.

Attempts to use the following querystring parameters from the request:
`mode_slug` (str): The mode to add, either 'honor', 'verified', or 'professional'
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def get_next_url_for_login_page(request, include_host=False):
# Append a tpa_hint query parameter, if one is configured
tpa_hint = configuration_helpers.get_value(
"THIRD_PARTY_AUTH_HINT",
settings.FEATURES.get("THIRD_PARTY_AUTH_HINT", '')
settings.THIRD_PARTY_AUTH_HINT
)
if tpa_hint:
# Don't add tpa_hint if we're already in the TPA pipeline (prevent infinite loop),
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def validate_login():
next_page = get_next_url_for_login_page(req)
assert next_page == expected_url

with override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT=tpa_hint)):
with override_settings(THIRD_PARTY_AUTH_HINT=tpa_hint):
validate_login()

with with_site_configuration_context(configuration=dict(THIRD_PARTY_AUTH_HINT=tpa_hint)):
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/certificates/generation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,4 @@ def _id_verification_enforced_and_missing(user):
"""
Return true if IDV is required for this course and the user does not have it
"""
return settings.FEATURES.get(
'ENABLE_CERTIFICATES_IDV_REQUIREMENT') and not IDVerificationService.user_is_verified(user)
return settings.ENABLE_CERTIFICATES_IDV_REQUIREMENT and not IDVerificationService.user_is_verified(user)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from unittest import mock

import pytest
from django.conf import settings
from django.core.management import CommandError, call_command
from django.test import override_settings

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
Expand All @@ -25,7 +25,7 @@

# base setup is unverified users, Enable certificates IDV requirements turned off,
# and normal passing grade certificates for convenience
@mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=False)
@override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=False)
@mock.patch(ID_VERIFIED_METHOD, mock.Mock(return_value=False))
@mock.patch(PASSING_GRADE_METHOD, mock.Mock(return_value=True))
@mock.patch(WEB_CERTS_METHOD, mock.Mock(return_value=True))
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/certificates/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import ddt
import pytz
from config_models.models import cache
from django.conf import settings
from django.test import RequestFactory, TestCase
from django.test.utils import override_settings
from django.urls import reverse
Expand Down Expand Up @@ -553,7 +552,7 @@ def test_generation_unverified(self, enable_idv_requirement):

with mock.patch(PASSING_GRADE_METHOD, return_value=True):
with mock.patch(ID_VERIFIED_METHOD, return_value=False):
with mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
with override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
generate_certificate_task(self.user, self.course_run_key)

cert = get_certificate_for_user_id(self.user.id, self.course_run_key)
Expand Down
13 changes: 6 additions & 7 deletions lms/djangoapps/certificates/tests/test_generation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from unittest import mock

import ddt
from django.conf import settings
from django.test import override_settings

from common.djangoapps.course_modes.models import CourseMode
Expand Down Expand Up @@ -209,7 +208,7 @@ def test_can_generate_not_verified(self, enable_idv_requirement):
Test handling when the user's id is not verified
"""
with mock.patch(ID_VERIFIED_METHOD, return_value=False), \
mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
self.assertNotEqual( # noqa: PT009
enable_idv_requirement,
_can_generate_allowlist_certificate(self.user, self.course_run_key, self.enrollment_mode))
Expand Down Expand Up @@ -360,7 +359,7 @@ def test_generate_allowlist_honor_cert(self):
assert not _can_generate_allowlist_certificate(self.user, course_run_key, enrollment_mode)


@mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=False)
@override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=False)
@mock.patch(ID_VERIFIED_METHOD, mock.Mock(return_value=True))
@mock.patch(CCX_COURSE_METHOD, mock.Mock(return_value=False))
@mock.patch(PASSING_GRADE_METHOD, mock.Mock(return_value=True))
Expand Down Expand Up @@ -537,7 +536,7 @@ def test_can_generate_not_verified_cert(self, enable_idv_requirement):
)

with mock.patch(ID_VERIFIED_METHOD, return_value=False), \
mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
self.assertNotEqual( # noqa: PT009
enable_idv_requirement,
_can_generate_regular_certificate(u, self.course_run_key, self.enrollment_mode, self.grade)
Expand All @@ -559,7 +558,7 @@ def test_can_generate_not_verified_no_cert(self, enable_idv_requirement):
)

with mock.patch(ID_VERIFIED_METHOD, return_value=False), \
mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement):
self.assertNotEqual( # noqa: PT009
enable_idv_requirement,
_can_generate_regular_certificate(u, self.course_run_key, self.enrollment_mode, self.grade)
Expand Down Expand Up @@ -587,7 +586,7 @@ def test_can_generate_not_verified_not_passing(self, enable_idv_requirement):
)

with mock.patch(ID_VERIFIED_METHOD, return_value=False), \
mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement), \
override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement), \
mock.patch(PASSING_GRADE_METHOD, return_value=False):
assert not _can_generate_regular_certificate(u, self.course_run_key, self.enrollment_mode, self.grade)
if enable_idv_requirement:
Expand Down Expand Up @@ -617,7 +616,7 @@ def test_can_generate_not_verified_not_passing_allowlist(self, enable_idv_requir
CertificateAllowlistFactory(course_id=self.course_run_key, user=u)

with mock.patch(ID_VERIFIED_METHOD, return_value=False), \
mock.patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement), \
override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_idv_requirement), \
mock.patch(PASSING_GRADE_METHOD, return_value=False):
assert not _can_generate_regular_certificate(u, self.course_run_key, self.enrollment_mode, self.grade)
if enable_idv_requirement:
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/certificates/tests/test_webview_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ def test_verified_certificate_description(self, enable_cert_idv_requirement):
"""
Test that for a verified cert, the correct language is used when the integrity signature feature is enabled.
"""
with patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_cert_idv_requirement):
with override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_cert_idv_requirement):
self._add_course_certificates(count=1, signatory_count=2, is_active=True)
self._create_custom_template_with_verified_description()
self.cert.mode = 'verified'
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/certificates/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_certificate_description(mode, certificate_type, platform_name, course_ke
"{platform_name} and has completed all of the required tasks for this course "
"under its guidelines. ").format(cert_type=certificate_type,
platform_name=platform_name)
if settings.FEATURES.get('ENABLE_CERTIFICATES_IDV_REQUIREMENT'):
if settings.ENABLE_CERTIFICATES_IDV_REQUIREMENT:
certificate_type_description += _("A {cert_type} certificate also indicates that the "
"identity of the learner has been checked and "
"is valid.").format(cert_type=certificate_type)
Expand Down Expand Up @@ -249,7 +249,7 @@ def _update_course_context(request, context, course, platform_name):
context['accomplishment_copy_course_name'] = accomplishment_copy_course_name
course_number = course.display_coursenumber if course.display_coursenumber else course.number
context['course_number'] = course_number
context['idv_enabled_for_certificates'] = settings.FEATURES.get('ENABLE_CERTIFICATES_IDV_REQUIREMENT')
context['idv_enabled_for_certificates'] = settings.ENABLE_CERTIFICATES_IDV_REQUIREMENT
if context['organization_long_name']:
# Translators: This text represents the description of course
context['accomplishment_copy_course_description'] = _('a course of study offered by {partner_short_name}, '
Expand Down
4 changes: 1 addition & 3 deletions lms/djangoapps/course_home_api/outline/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,7 @@ def test_blocks_complete_with_library_content_block(
self.create_completion(problem, int(problem_complete))
self.create_completion(library, int(library_complete))

with override_settings(
FEATURES={**settings.FEATURES, 'MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW': library_complete_on_view}
):
with override_settings(MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW=library_complete_on_view):
response = self.client.get(reverse('course-home:course-navigation', args=[self.course.id]))

sequence_data = response.data['blocks'][str(self.sequential.location)]
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def get_history(student_modules):

# If we turn off reading from multiple history tables, then we don't want to read from
# StudentModuleHistory anymore, we believe that all history is in the Extended table.
if settings.FEATURES.get('ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES'):
if settings.ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES:
# we want to save later SQL queries on the model which allows us to prefetch
history_entries += StudentModuleHistory.objects.prefetch_related('student_module').filter(
student_module__in=student_modules
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ def test_progress_queries(self):
), check_mongo_calls(2):
self._get_progress_page()

@patch.dict(settings.FEATURES, {'ENABLE_CERTIFICATES_IDV_REQUIREMENT': True})
@override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=True)
@ddt.data(
*itertools.product(
(
Expand Down Expand Up @@ -1581,7 +1581,7 @@ def test_no_certs_generated_and_not_verified(self, enable_cert_idv_requirement):
"""
certs_api.set_certificate_generation_config(enabled=True)
certs_api.set_cert_generation_enabled(self.course.id, True)
with patch.dict(settings.FEATURES, ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_cert_idv_requirement):
with override_settings(ENABLE_CERTIFICATES_IDV_REQUIREMENT=enable_cert_idv_requirement):
with patch(
'lms.djangoapps.certificates.api.certificate_downloadable_status',
return_value=self.mock_certificate_downloadable_status()
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def _downloadable_certificate_message(course, cert_downloadable_status): # pyli


def _missing_required_verification(student, enrollment_mode):
return settings.FEATURES.get('ENABLE_CERTIFICATES_IDV_REQUIREMENT') and (
return settings.ENABLE_CERTIFICATES_IDV_REQUIREMENT and (
enrollment_mode in CourseMode.VERIFIED_MODES and not IDVerificationService.user_is_verified(student)
)

Expand Down
13 changes: 4 additions & 9 deletions lms/djangoapps/coursewarehistoryextended/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import json
from unittest import skipUnless
from unittest.mock import patch

from django.conf import settings
from django.db import connections
Expand Down Expand Up @@ -43,8 +42,7 @@ def setUp(self):
max_grade=csm.max_grade)
csmh.save()

@override_settings(ENABLE_CSMH_EXTENDED=True)
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES": True})
@override_settings(ENABLE_CSMH_EXTENDED=True, ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES=True)
def test_get_history_true_true(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
Expand All @@ -56,8 +54,7 @@ def test_get_history_true_true(self):
assert {'type': 'csmh', 'order': 2} == json.loads(history[4].state)
assert {'type': 'csmh', 'order': 1} == json.loads(history[5].state)

@override_settings(ENABLE_CSMH_EXTENDED=True)
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES": False})
@override_settings(ENABLE_CSMH_EXTENDED=True, ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES=False)
def test_get_history_true_false(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
Expand All @@ -66,8 +63,7 @@ def test_get_history_true_false(self):
assert {'type': 'csmhe', 'order': 2} == json.loads(history[1].state)
assert {'type': 'csmhe', 'order': 1} == json.loads(history[2].state)

@override_settings(ENABLE_CSMH_EXTENDED=False)
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES": True})
@override_settings(ENABLE_CSMH_EXTENDED=False, ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES=True)
def test_get_history_false_true(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
Expand All @@ -76,8 +72,7 @@ def test_get_history_false_true(self):
assert {'type': 'csmh', 'order': 2} == json.loads(history[1].state)
assert {'type': 'csmh', 'order': 1} == json.loads(history[2].state)

@override_settings(ENABLE_CSMH_EXTENDED=False)
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES": False})
@override_settings(ENABLE_CSMH_EXTENDED=False, ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES=False)
def test_get_history_false_false(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/grades/subsection_grade_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def update(self, subsection, only_if_higher=None, score_deleted=False, force_upd
)
self._update_saved_subsection_grade(subsection.location, grade_model)

if settings.FEATURES.get('ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL'):
if settings.ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL:
COURSE_ASSESSMENT_GRADE_CHANGED.send(
sender=self,
course_id=self.course_data.course_key,
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/grades/tests/test_subsection_grade_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest.mock import patch

import ddt
from django.conf import settings
from django.test import override_settings

from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_create_zero(self):
assert isinstance(grade, ZeroSubsectionGrade)
self.assert_grade(grade, 0.0, 1.0)

@patch.dict(settings.FEATURES, {'ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL': True})
@override_settings(ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL=True)
def test_update(self):
"""
Assuming the underlying score reporting methods work,
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/tasks_helper/grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def _build_student_data(
])

student_data = []
max_count = settings.FEATURES.get('MAX_PROBLEM_RESPONSES_COUNT')
max_count = settings.MAX_PROBLEM_RESPONSES_COUNT

store = modulestore()
user_state_client = DjangoXBlockUserStateClient()
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/tests/test_tasks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _remove_capa_report_generator(self):
finally:
ProblemBlock.generate_report_data = generate_report_data

@patch.dict('django.conf.settings.FEATURES', {'MAX_PROBLEM_RESPONSES_COUNT': 4})
@override_settings(MAX_PROBLEM_RESPONSES_COUNT=4)
def test_build_student_data_limit(self):
"""
Ensure that the _build_student_data method respects the global setting for
Expand Down
2 changes: 1 addition & 1 deletion lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@
]

# Bulk User Retirement API urls
if settings.FEATURES.get('ENABLE_BULK_USER_RETIREMENT'):
if settings.ENABLE_BULK_USER_RETIREMENT:
urlpatterns += [
path('', include('lms.djangoapps.bulk_user_retirement.urls')),
]
Expand Down
Loading
Loading