Skip to content

Commit

Permalink
feat: added transcript_languages_search_facet_names to CourseRunSeria…
Browse files Browse the repository at this point in the history
…lizer
  • Loading branch information
Maham Akif authored and Maham Akif committed Mar 25, 2024
1 parent 7b34f30 commit b840fa0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer):
required=False, many=True, slug_field='code',
queryset=LanguageTag.objects.prefetch_related('translations').order_by('name')
)
transcript_languages_search_facet_names = serializers.SerializerMethodField()
video = VideoSerializer(required=False, allow_null=True, source='get_video')
instructors = serializers.SerializerMethodField(help_text='This field is deprecated. Use staff.')
staff = SlugRelatedFieldWithReadSerializer(slug_field='uuid', required=False, many=True,
Expand Down Expand Up @@ -1066,10 +1067,11 @@ class Meta(MinimalCourseRunSerializer.Meta):
'level_type', 'mobile_available', 'hidden', 'reporting_type', 'eligible_for_financial_aid',
'first_enrollable_paid_seat_price', 'has_ofac_restrictions', 'ofac_comment',
'enrollment_count', 'recent_enrollment_count', 'expected_program_type', 'expected_program_name',
'course_uuid', 'estimated_hours', 'content_language_search_facet_name', 'enterprise_subscription_inclusion'
'course_uuid', 'estimated_hours', 'content_language_search_facet_name', 'enterprise_subscription_inclusion',
'transcript_languages_search_facet_names'
)
read_only_fields = ('enrollment_count', 'recent_enrollment_count', 'content_language_search_facet_name',
'enterprise_subscription_inclusion')
'enterprise_subscription_inclusion', 'transcript_languages_search_facet_names')

def get_instructors(self, obj): # pylint: disable=unused-argument
# This field is deprecated. Use the staff field.
Expand All @@ -1084,6 +1086,17 @@ def get_content_language_search_facet_name(self, obj):
return None
return language.get_search_facet_display(translate=True)

def get_transcript_languages_search_facet_names(self, obj):
transcript_languages = obj.transcript_languages.all()
if not transcript_languages:
return None

transcript_languages_facet_names = []
for language in transcript_languages:
transcript_languages_facet_names.append(language.get_search_facet_display(translate=True))

return transcript_languages_facet_names

def update_video(self, instance, video_data):
# A separate video object is a historical concept. These days, we really just use the link address. So
# we look up a foreign key just based on the link and don't bother trying to match or set any other fields.
Expand Down
1 change: 1 addition & 0 deletions course_discovery/apps/api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def get_expected_data(cls, course_run, request):
'ofac_comment': course_run.ofac_comment,
'estimated_hours': get_course_run_estimated_hours(course_run),
'enterprise_subscription_inclusion': course_run.enterprise_subscription_inclusion,
'transcript_languages_search_facet_names': None
})
return expected

Expand Down

0 comments on commit b840fa0

Please sign in to comment.