Skip to content

Commit cb7f0f4

Browse files
nsprenkleCopilot
andauthored
fix: fix bad serialization of courseware metadata (#37338)
* Formats single_paid_mode as a dict, rather than named tuple which couldn't be serialized to DictField * Allow ecommerce_checkout_link to be empty Co-authored-by: Copilot <[email protected]>
1 parent b9becde commit cb7f0f4

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

openedx/core/djangoapps/courseware_api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract-
133133
allow_anonymous = serializers.BooleanField()
134134
ecommerce_checkout = serializers.BooleanField()
135135
single_paid_mode = serializers.DictField()
136-
ecommerce_checkout_link = AbsoluteURLField()
136+
ecommerce_checkout_link = AbsoluteURLField(allow_null=True)
137137
course_image_urls = serializers.ListField(
138138
child=serializers.CharField(),
139139
allow_empty=True,

openedx/core/djangoapps/courseware_api/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,14 @@ def single_paid_mode(self):
454454
else:
455455
# have professional ignore other modes for historical reasons
456456
single_paid_mode = modes.get(CourseMode.PROFESSIONAL)
457-
return single_paid_mode
457+
if single_paid_mode:
458+
return {
459+
"sku": single_paid_mode.sku,
460+
"name": single_paid_mode.name,
461+
"min_price": single_paid_mode.min_price,
462+
"description": single_paid_mode.description,
463+
}
464+
return {}
458465

459466
@property
460467
def ecommerce_checkout_link(self):
@@ -629,7 +636,6 @@ class CoursewareInformation(RetrieveAPIView):
629636
* name: (str) The name of the single paid mode
630637
* min_price: (str) The minimum price for the single paid mode, formatted with the currency symbol
631638
* description: (str) The description of the single paid mode
632-
* is_discounted: (bool) Whether the single paid mode is discounted
633639
* ecommerce_checkout_link: The ecommerce checkout link for the course, if it exists
634640
* course_image_urls: A list of course image URLs
635641
* start_date_is_still_default: Whether the course start date is still the default value

0 commit comments

Comments
 (0)