Skip to content

Commit

Permalink
Use custom search filter generator to show course tiles for discovery…
Browse files Browse the repository at this point in the history
… search
  • Loading branch information
kluo committed Feb 27, 2019
1 parent 1f75d29 commit 4f23ed3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions openedx/stanford/lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
# The following fields are available in the URL: {course_id} {student_id}
PROGRESS_SUCCESS_BUTTON_URL = 'http://<domain>/<path>/{course_id}'
PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE = None
SEARCH_FILTER_GENERATOR = 'openedx.stanford.lms.lib.courseware_search.lms_filter_generator.TileSearchFilterGenerator'
SHIB_REDIRECT_DOMAIN_WHITELIST = {
# Mapping of hosts to a list of safe redirect domains from that host
# (not including itself); e.g.
Expand Down
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Custom override of SearchFilterGenerator to use course tiles for
discovery search.
"""
from search.filter_generator import SearchFilterGenerator

from branding_stanford.models import TileConfiguration
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator


class TileSearchFilterGenerator(LmsSearchFilterGenerator):
"""
SearchFilterGenerator for LMS Search.
"""

def field_dictionary(self, **kwargs):
"""
Return field filter dictionary for search.
"""
field_dictionary = super(TileSearchFilterGenerator, self).field_dictionary(**kwargs)
if not kwargs.get('user'):
# Adds tile courses for discovery search
course_tiles_ids = TileConfiguration.objects.filter(
enabled=True,
).values_list('course_id', flat=True).order_by('-change_date')
field_dictionary['course'] = list(course_tiles_ids)
return field_dictionary
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ edx-oauth2-provider==1.2.0
edx-opaque-keys==0.4.0
edx-organizations==0.4.4
edx-rest-api-client==1.7.1
edx-search==1.0.1
git+https://github.com/Stanford-Online/edx-search.git@e2aba4a30cf2dc6aa901799596161a59fa3e3baa#egg=edx-search==1.2.1
facebook-sdk==0.4.0
feedparser==5.1.3
firebase-token-generator==1.3.2
Expand Down

0 comments on commit 4f23ed3

Please sign in to comment.