Commit 2d50e7ba by Clinton Blackburn Committed by GitHub

Added content_type field to programs search results (#165)

parent d8040e67
...@@ -44,6 +44,10 @@ COURSE_RUN_SEARCH_FIELDS = ( ...@@ -44,6 +44,10 @@ COURSE_RUN_SEARCH_FIELDS = (
'image_url', 'type', 'text', 'image_url', 'type', 'text',
) )
PROGRAM_SEARCH_FIELDS = (
'uuid', 'name', 'subtitle', 'category', 'marketing_url', 'organizations', 'content_type', 'text',
)
def get_marketing_url_for_user(user, marketing_url): def get_marketing_url_for_user(user, marketing_url):
""" """
...@@ -495,7 +499,7 @@ class CourseRunFacetSerializer(BaseHaystackFacetSerializer): ...@@ -495,7 +499,7 @@ class CourseRunFacetSerializer(BaseHaystackFacetSerializer):
class ProgramSearchSerializer(HaystackSerializer): class ProgramSearchSerializer(HaystackSerializer):
class Meta: class Meta:
field_aliases = COMMON_SEARCH_FIELD_ALIASES field_aliases = COMMON_SEARCH_FIELD_ALIASES
fields = ('uuid', 'name', 'subtitle', 'category', 'marketing_url', 'organizations', 'text',) fields = PROGRAM_SEARCH_FIELDS
ignore_fields = COMMON_IGNORED_FIELDS ignore_fields = COMMON_IGNORED_FIELDS
index_classes = [ProgramIndex] index_classes = [ProgramIndex]
...@@ -505,7 +509,7 @@ class ProgramFacetSerializer(BaseHaystackFacetSerializer): ...@@ -505,7 +509,7 @@ class ProgramFacetSerializer(BaseHaystackFacetSerializer):
class Meta: class Meta:
field_aliases = COMMON_SEARCH_FIELD_ALIASES field_aliases = COMMON_SEARCH_FIELD_ALIASES
fields = ('uuid', 'name', 'subtitle', 'category', 'marketing_url', 'organizations', 'text',) fields = PROGRAM_SEARCH_FIELDS
ignore_fields = COMMON_IGNORED_FIELDS ignore_fields = COMMON_IGNORED_FIELDS
index_classes = [ProgramIndex] index_classes = [ProgramIndex]
......
...@@ -397,5 +397,6 @@ class ProgramSearchSerializerTests(TestCase): ...@@ -397,5 +397,6 @@ class ProgramSearchSerializerTests(TestCase):
'category': program.category, 'category': program.category,
'marketing_url': program.marketing_url, 'marketing_url': program.marketing_url,
'organizations': [OrganizationsMixin.format_organization(organization)], 'organizations': [OrganizationsMixin.format_organization(organization)],
'content_type': 'program_{category}'.format(category=program.category),
} }
self.assertDictEqual(serializer.data, expected) self.assertDictEqual(serializer.data, expected)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment