forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use custom search filter generator to show course tiles for discovery…
… search
- Loading branch information
Showing
5 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions
27
openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters