Merge pull request #22451 from edx/ormsbee/course_staff_search_preview
Add ENABLE_COURSEWARE_SEARCH_FOR_COURSE_STAFF flag
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user