fix: correct course catalog visibility for "about" setting

Previously, courses with the "Course Visibility in Catalog" setting set to "about"
still appeared in the course catalog, which contradicts the expected behavior.
This commit is contained in:
Turchanikov Arsen
2025-05-22 17:17:36 +03:00
committed by Arsen Turchanikov
parent bcb3f6b996
commit cd57ecef81
2 changed files with 9 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartiti
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from common.djangoapps.student.models import CourseEnrollment
from xmodule.course_block import CATALOG_VISIBILITY_ABOUT, CATALOG_VISIBILITY_NONE
INCLUDE_SCHEMES = [CohortPartitionScheme, RandomUserPartitionScheme, ]
SCHEME_SUPPORTS_ASSIGNMENT = [RandomUserPartitionScheme, ]
@@ -63,6 +64,6 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
if not getattr(settings, "SEARCH_SKIP_INVITATION_ONLY_FILTERING", True):
exclude_dictionary['invitation_only'] = True
if not getattr(settings, "SEARCH_SKIP_SHOW_IN_CATALOG_FILTERING", True):
exclude_dictionary['catalog_visibility'] = 'none'
exclude_dictionary['catalog_visibility'] = [CATALOG_VISIBILITY_ABOUT, CATALOG_VISIBILITY_NONE]
return exclude_dictionary

View File

@@ -6,6 +6,7 @@ from unittest.mock import Mock, patch
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import UserFactory
from xmodule.course_block import CATALOG_VISIBILITY_ABOUT, CATALOG_VISIBILITY_NONE
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
@@ -139,3 +140,9 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
assert 'org' not in exclude_dictionary
assert 'org' in field_dictionary
assert ['TestSite3'] == field_dictionary['org']
@patch('django.conf.settings.SEARCH_SKIP_SHOW_IN_CATALOG_FILTERING', False)
def test_excludes_catalog_visibility(self):
_, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
assert 'catalog_visibility' in exclude_dictionary
assert exclude_dictionary['catalog_visibility'] == [CATALOG_VISIBILITY_ABOUT, CATALOG_VISIBILITY_NONE]