From b12434484d8f09c1e34a9ca8ed1cadff0a4804fe Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Mon, 12 Aug 2024 19:53:55 +0500 Subject: [PATCH] chore: update course_run_detail method in CourseSearchDocument serializer (#4408) * chore: update course_run_detail method in CourseSearchDocument serializer * fix: serializer * test: update serialier results * refactor: unwanted code * test: fixed another test-case * chore: test fixups --- course_discovery/apps/api/tests/test_serializers.py | 6 ++++-- .../course_metadata/search_indexes/serializers/course.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/course_discovery/apps/api/tests/test_serializers.py b/course_discovery/apps/api/tests/test_serializers.py index 380e06b90e..33abb93f33 100644 --- a/course_discovery/apps/api/tests/test_serializers.py +++ b/course_discovery/apps/api/tests/test_serializers.py @@ -2351,7 +2351,8 @@ def test_detail_fields_in_response(self, is_post_request): 'content_language': course_run.language.code if course_run.language else None, 'restriction_type': ( course_run.restricted_run.restriction_type if hasattr(course_run, 'restricted_run') else None - ) + ), + 'fixed_price_usd': float(course_run.fixed_price_usd), }], 'uuid': str(course.uuid), 'subjects': [subject.name for subject in course.subjects.all()], @@ -2424,7 +2425,8 @@ def get_expected_data(cls, course, course_run, course_skill, seat): 'is_enrollable': course_run.is_enrollable, 'restriction_type': ( course_run.restricted_run.restriction_type if hasattr(course_run, 'restricted_run') else None - ) + ), + 'fixed_price_usd': float(course_run.fixed_price_usd), }], 'uuid': str(course.uuid), 'subjects': [subject.name for subject in course.subjects.all()], diff --git a/course_discovery/apps/course_metadata/search_indexes/serializers/course.py b/course_discovery/apps/course_metadata/search_indexes/serializers/course.py index 60379287d2..b8e277dd0c 100644 --- a/course_discovery/apps/course_metadata/search_indexes/serializers/course.py +++ b/course_discovery/apps/course_metadata/search_indexes/serializers/course.py @@ -74,6 +74,7 @@ def course_run_detail(self, request, detail_fields, course_run): 'restriction_type': ( course_run.restricted_run.restriction_type if hasattr(course_run, 'restricted_run') else None ), + 'fixed_price_usd': float(course_run.fixed_price_usd) if course_run.fixed_price_usd else None, } if detail_fields: course_run_detail.update(