Skip to content
Draft
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/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ def get_allowed_organizations_for_libraries(user):
# This allows org-level staff to create libraries. We should re-evaluate
# whether this is necessary and try to normalize course and library creation
# authorization behavior.
if settings.FEATURES.get('ENABLE_ORGANIZATION_STAFF_ACCESS_FOR_CONTENT_LIBRARIES', False):
if settings.ENABLE_ORGANIZATION_STAFF_ACCESS_FOR_CONTENT_LIBRARIES:
organizations_set.update(get_organizations_for_non_course_creators(user))

# This allows people in the course creator group for an org to create
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ def enforce_single_login(sender, request, user, signal, **kwargs): # pylint: di
Sets the current session id in the user profile,
to prevent concurrent logins.
"""
if settings.FEATURES.get('PREVENT_CONCURRENT_LOGINS', False):
if settings.PREVENT_CONCURRENT_LOGINS:
if signal == user_logged_in:
key = request.session.session_key
else:
Expand Down
5 changes: 1 addition & 4 deletions common/djangoapps/student/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ddt
from crum import set_current_request
from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User # pylint: disable=imported-auth-user
from django.core.cache import cache
from django.db import connection
Expand Down Expand Up @@ -912,9 +911,7 @@ def register_and_enroll_student():
course_overview.save()

if feature_enabled:
with override_settings(
FEATURES={**settings.FEATURES, 'DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED': True}
):
with override_settings(DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED=True):
assert register_and_enroll_student() is None
else:
assert register_and_enroll_student() is not None
Expand Down
8 changes: 4 additions & 4 deletions common/djangoapps/student/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def test_happy_path_upgrade_message(


@skip_unless_lms
@unittest.skipUnless(settings.FEATURES.get("ENABLE_NOTICES"), 'Notices plugin is not enabled')
@unittest.skipUnless(getattr(settings, "ENABLE_NOTICES", False), 'Notices plugin is not enabled')
class TestCourseDashboardNoticesRedirects(SharedModuleStoreTestCase):
"""
Tests for the Dashboard redirect functionality introduced via the Notices plugin.
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def test_user_with_unacknowledged_notice(self, mock_notices):
"""
mock_notices.return_value = reverse("about")

with override_settings(FEATURES={**settings.FEATURES, 'ENABLE_NOTICES': True}):
with override_settings(ENABLE_NOTICES=True):
response = self.client.get(self.path)

assert response.status_code == 302
Expand All @@ -1104,7 +1104,7 @@ def test_user_with_unacknowledged_notice_no_notices(self, mock_notices):
"""
mock_notices.return_value = None

with override_settings(FEATURES={**settings.FEATURES, 'ENABLE_NOTICES': True}):
with override_settings(ENABLE_NOTICES=True):
response = self.client.get(self.path)

assert response.status_code == 200
Expand All @@ -1117,7 +1117,7 @@ def test_user_with_unacknowledged_notice_plugin_disabled(self, mock_notices):
"""
mock_notices.return_value = None

with override_settings(FEATURES={**settings.FEATURES, 'ENABLE_NOTICES': False}):
with override_settings(ENABLE_NOTICES=False):
response = self.client.get(self.path)

assert response.status_code == 200
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def student_dashboard(request): # pylint: disable=too-many-statements
) or settings.SUPPORT_SITE_LINK
hide_dashboard_courses_until_activated = configuration_helpers.get_value(
'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED',
settings.FEATURES.get('HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED', False)
getattr(settings, 'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED', False)
)
empty_dashboard_message = configuration_helpers.get_value(
'EMPTY_DASHBOARD_MESSAGE', None
Expand Down
4 changes: 2 additions & 2 deletions common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def compose_activation_email(
})

if route_enabled:
dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']
dest_addr = getattr(settings, 'REROUTE_ACTIVATION_EMAIL', False)
else:
dest_addr = user.email

Expand Down Expand Up @@ -293,7 +293,7 @@ def compose_and_send_activation_email(
redirect_url: The URL to redirect to after successful activation
registration_flow: Is the request coming from registration workflow
"""
route_enabled = settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL')
route_enabled = getattr(settings, 'REROUTE_ACTIVATION_EMAIL', False)

msg = compose_activation_email(
user, user_registration, route_enabled, profile.name, redirect_url, registration_flow
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _can_enroll_courselike(user, courselike):
# DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED flag is used to disable enrollment for user invited
# to a course if user is registering when the course enrollment is closed
if (
settings.FEATURES.get('DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED') and
settings.DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED and
not course_enrollment_open and
not user_has_staff_access
):
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/block_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,9 +1005,9 @@ def xblock_view(request, course_id, usage_id, view_name):
resources: A list of tuples where the first element is the resource hash, and
the second is the resource description
"""
if not settings.FEATURES.get('ENABLE_XBLOCK_VIEW_ENDPOINT', False):
if not settings.ENABLE_XBLOCK_VIEW_ENDPOINT:
log.warning("Attempt to use deactivated XBlock view endpoint -"
" see FEATURES['ENABLE_XBLOCK_VIEW_ENDPOINT']")
" see ENABLE_XBLOCK_VIEW_ENDPOINT")
raise Http404

try:
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/courseware/tests/test_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import pytest
import pytz
from ccx_keys.locator import CCXLocator
from django.conf import settings
from django.contrib.auth.models import User # pylint: disable=imported-auth-user
from django.test import TestCase
from django.test.client import RequestFactory
Expand Down Expand Up @@ -551,7 +550,7 @@ def test__has_access_course_can_enroll(self):
course.save()
assert not access._has_access_course(user, 'enroll', course)

@override_settings(FEATURES={**settings.FEATURES, 'DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED': True})
@override_settings(DISABLE_ALLOWED_ENROLLMENT_IF_ENROLLMENT_CLOSED=True)
def test__has_access_course_with_disable_allowed_enrollment_flag(self):
yesterday = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1)
tomorrow = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1)
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_block_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def test_will_recheck_access_handler_attribute(self, handler, will_recheck_acces


@ddt.ddt
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_XBLOCK_VIEW_ENDPOINT': True})
@override_settings(ENABLE_XBLOCK_VIEW_ENDPOINT=True)
class TestXBlockView(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
"""
Test the handle_xblock_callback function
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/views/instructor_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def _section_open_response_assessment(request, course, openassessment_blocks, ac
section_data = {
'fragment': block.render('ora_blocks_listing_view', context={
'ora_items': ora_items,
'ora_item_view_enabled': settings.FEATURES.get('ENABLE_XBLOCK_VIEW_ENDPOINT', False)
'ora_item_view_enabled': settings.ENABLE_XBLOCK_VIEW_ENDPOINT
}),
'section_key': 'open_response_assessment',
'section_display_name': _('Open Responses'),
Expand Down
2 changes: 1 addition & 1 deletion lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@
),
]

if settings.FEATURES.get('ENABLE_DEBUG_RUN_PYTHON'):
if settings.ENABLE_DEBUG_RUN_PYTHON:
urlpatterns += [
path('debug/run_python', debug_views.run_python),
]
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/user_authn/views/auto_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def auto_auth(request): # pylint: disable=too-many-statements
redirect_when_done = _str2bool(request.GET.get('redirect', '')) or redirect_to
login_when_done = 'no_login' not in request.GET

restricted = settings.FEATURES.get('RESTRICT_AUTOMATIC_AUTH', True)
restricted = settings.RESTRICT_AUTOMATIC_AUTH
if is_superuser and restricted:
return HttpResponseForbidden(_('Superuser creation not allowed'))

Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def _skip_activation_email(user, running_pipeline, third_party_provider):
)

return (
settings.FEATURES.get('SKIP_EMAIL_VALIDATION', None) or
getattr(settings, 'SKIP_EMAIL_VALIDATION', False) or
settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING') or
(third_party_provider and third_party_provider.skip_email_verification and valid_email)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ddt
from django.conf import settings
from django.contrib.auth.models import User # pylint: disable=imported-auth-user
from django.test import TestCase
from django.test import TestCase, override_settings
from django.test.client import Client
from opaque_keys.edx.locator import CourseLocator

Expand Down Expand Up @@ -67,7 +67,7 @@ def test_create_user(self):
assert user.is_active
assert not user.profile.requires_parental_consent()

@patch.dict("django.conf.settings.FEATURES", {'RESTRICT_AUTOMATIC_AUTH': False})
@override_settings(RESTRICT_AUTOMATIC_AUTH=False)
def test_create_same_user(self):
self._auto_auth({'username': 'test'})
self._auto_auth({'username': 'test'})
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_create_defined_user(self):
# By default, the user should not be global staff
assert not user.is_staff

@patch.dict("django.conf.settings.FEATURES", {'RESTRICT_AUTOMATIC_AUTH': False})
@override_settings(RESTRICT_AUTOMATIC_AUTH=False)
def test_create_staff_user(self):

# Create a staff user
Expand All @@ -132,7 +132,7 @@ def test_course_enrollment(self, course_id, course_key):

@ddt.data(*COURSE_IDS_DDT)
@ddt.unpack
@patch.dict("django.conf.settings.FEATURES", {'RESTRICT_AUTOMATIC_AUTH': False})
@override_settings(RESTRICT_AUTOMATIC_AUTH=False)
def test_double_enrollment(self, course_id, course_key):

# Create a user and enroll in a course
Expand Down Expand Up @@ -337,15 +337,15 @@ def setUp(self):
self.url = '/auto_auth'
self.client = Client()

@patch.dict("django.conf.settings.FEATURES", {'RESTRICT_AUTOMATIC_AUTH': True})
@override_settings(RESTRICT_AUTOMATIC_AUTH=True)
def test_superuser(self):
"""
Make sure that superusers cannot be created.
"""
response = self.client.get(self.url, {'username': 'test', 'superuser': 'true'})
assert response.status_code == 403

@patch.dict("django.conf.settings.FEATURES", {'RESTRICT_AUTOMATIC_AUTH': True})
@override_settings(RESTRICT_AUTOMATIC_AUTH=True)
def test_modify_user(self):
"""
Make sure that existing users cannot be modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def test_login_refresh_anonymous_user(self):
assert response.status_code == 401
assert jwt_cookies.jwt_cookie_header_payload_name() not in self.client.cookies

@patch.dict("django.conf.settings.FEATURES", {'PREVENT_CONCURRENT_LOGINS': True})
@override_settings(PREVENT_CONCURRENT_LOGINS=True)
def test_single_session(self):
creds = {'email': self.user_email, 'password': self.password}
client1 = Client()
Expand Down Expand Up @@ -658,7 +658,7 @@ def test_single_session(self):
# client1 will be logged out
assert response.status_code == 302

@patch.dict("django.conf.settings.FEATURES", {'PREVENT_CONCURRENT_LOGINS': True})
@override_settings(PREVENT_CONCURRENT_LOGINS=True)
def test_single_session_with_no_user_profile(self):
"""
Assert that user login with cas (Central Authentication Service) is
Expand Down Expand Up @@ -700,7 +700,7 @@ def test_single_session_with_no_user_profile(self):
# client1 will be logged out
assert response.status_code == 302

@patch.dict("django.conf.settings.FEATURES", {'PREVENT_CONCURRENT_LOGINS': True})
@override_settings(PREVENT_CONCURRENT_LOGINS=True)
def test_single_session_with_url_not_having_login_required_decorator(self):
# accessing logout url as it does not have login-required decorator it will avoid redirect
# and go inside the enforce_single_login
Expand Down
Loading