Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Seats Field to CourseRun Search API #92

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,7 @@ class CourseRunSearchSerializer(HaystackSerializer):
first_enrollable_paid_seat_price = serializers.SerializerMethodField()
type = serializers.SerializerMethodField()
is_enrollable = serializers.SerializerMethodField()
seats = serializers.SerializerMethodField()

def get_availability(self, result):
return result.object.availability
Expand All @@ -2221,6 +2222,10 @@ def get_type(self, result):

def get_is_enrollable(self, result):
return result.object.is_enrollable

def get_seats(self, result):
seats = result.object.seats.all()
return SeatSerializer(seats, many=True).data

class Meta:
field_aliases = COMMON_SEARCH_FIELD_ALIASES
Expand Down Expand Up @@ -2254,6 +2259,7 @@ class Meta:
'program_types',
'published',
'seat_types',
'seats',
'short_description',
'staff_uuids',
'start',
Expand Down