diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 0dd7ce00a2e0024a72b2fae67c9152e640163157..18d95218c9ba911f8dfe8d66e58a05c32d203c9b 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -409,6 +409,10 @@ class CoursewareIndex(View): """ course_url_name = default_course_url_name(self.course.id) course_url = reverse(course_url_name, kwargs={'course_id': six.text_type(self.course.id)}) + show_search = ( + settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH') or + (settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF') and self.is_staff) + ) courseware_context = { 'csrf': csrf(self.request)['csrf_token'], @@ -430,6 +434,7 @@ class CoursewareIndex(View): 'section_title': None, 'sequence_title': None, 'disable_accordion': COURSE_OUTLINE_PAGE_FLAG.is_enabled(self.course.id), + 'show_search': show_search, } courseware_context.update( get_experiment_user_metadata_context( diff --git a/lms/envs/common.py b/lms/envs/common.py index cdb1a4f398fc2af22f32458f14b7f2ea659566bb..7c2274edb417cfbbabbb5d511a66b354554cc0ff 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -294,6 +294,7 @@ FEATURES = { # Courseware search feature 'ENABLE_COURSEWARE_SEARCH': False, + 'ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF': False, # Dashboard search feature 'ENABLE_DASHBOARD_SEARCH': False, diff --git a/lms/envs/devstack_docker.py b/lms/envs/devstack_docker.py index d88a7cb384c8541c2eef85df73162e9d0c716670..83c128a2670a28a61f330bbecb3c6c6d551721bb 100644 --- a/lms/envs/devstack_docker.py +++ b/lms/envs/devstack_docker.py @@ -34,6 +34,7 @@ JWT_AUTH.update({ FEATURES.update({ 'AUTOMATIC_AUTH_FOR_TESTING': True, 'ENABLE_COURSEWARE_SEARCH': False, + 'ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF': True, 'ENABLE_COURSE_DISCOVERY': False, 'ENABLE_DASHBOARD_SEARCH': False, 'ENABLE_DISCUSSION_SERVICE': True, diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 3cb573538e27a25f110cabd654ab8d5810100059..6dba5cd21ce9f7328cc70c21f382bbc6b92bc734 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -74,7 +74,7 @@ from openedx.features.course_experience import course_home_page_title, COURSE_OU <%static:js group='courseware'/> <%include file="/mathjax_include.html" args="disable_fast_preview=True"/> - % if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'): + % if show_search: <%static:require_module module_name="course_search/js/course_search_factory" class_name="CourseSearchFactory"> var courseId = $('.courseware-results').data('courseId'); CourseSearchFactory({ @@ -136,7 +136,7 @@ ${HTML(fragment.foot_html())} </a> </div> - % if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'): + % if show_search: <div id="courseware-search-bar" class="search-bar courseware-search-bar" role="search" aria-label="Course"> <form class="search-form"> <label for="course-search-input" class="sr">${_('Course Search')}</label> diff --git a/openedx/features/course_experience/templates/course_experience/course-home-fragment.html b/openedx/features/course_experience/templates/course_experience/course-home-fragment.html index ee08433af7565905470d718b7a9eb93acf66f461..879cd0782662fabef0210a27686735854a12941f 100644 --- a/openedx/features/course_experience/templates/course_experience/course-home-fragment.html +++ b/openedx/features/course_experience/templates/course_experience/course-home-fragment.html @@ -30,7 +30,7 @@ from openedx.features.course_experience import UNIFIED_COURSE_TAB_FLAG, SHOW_REV </nav> </div> <div class="page-header-secondary"> - % if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'): + % if show_search: <div class="page-header-search"> <form class="search-form input-group" role="search" action="${reverse('openedx.course_search.course_search_results', args=[course_key])}"> <label class="field-label sr-only" for="search" id="search-hint">${_('Search the course')}</label> diff --git a/openedx/features/course_experience/views/course_home.py b/openedx/features/course_experience/views/course_home.py index f56fe260666602d049177ba8de148e38e1a400e4..4dd62c0b81cd74bd9e4c33f5f935fb2ee625aed8 100644 --- a/openedx/features/course_experience/views/course_home.py +++ b/openedx/features/course_experience/views/course_home.py @@ -5,6 +5,7 @@ Views for the course home page. from __future__ import absolute_import import six +from django.conf import settings from django.template.context_processors import csrf from django.template.loader import render_to_string from django.urls import reverse @@ -211,6 +212,10 @@ class CourseHomeFragmentView(EdxFragmentView): upgrade_url = EcommerceService().upgrade_url(request.user, course_key) upgrade_price, has_discount = format_strikeout_price(request.user, course) + show_search = ( + settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH') or + (settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF') and user_access['is_staff']) + ) # Render the course home fragment context = { 'request': request, @@ -238,6 +243,7 @@ class CourseHomeFragmentView(EdxFragmentView): 'upgrade_price': upgrade_price, 'upgrade_url': upgrade_url, 'has_discount': has_discount, + 'show_search': show_search, } html = render_to_string('course_experience/course-home-fragment.html', context) return Fragment(html)