From 6018922a5241b4c87a9ce1cd62f1a37d496dcdec Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 8 Aug 2024 18:29:20 +0500 Subject: [PATCH] feat: add course and program availability --- courses/serializers.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/courses/serializers.py b/courses/serializers.py index e0e4142cd..fddcdb7da 100644 --- a/courses/serializers.py +++ b/courses/serializers.py @@ -113,6 +113,16 @@ class CourseSerializer(serializers.ModelSerializer): credits = serializers.SerializerMethodField() platform = serializers.SerializerMethodField() marketing_hubspot_form_id = serializers.SerializerMethodField() + availability = serializers.SerializerMethodField() + + def get_availability(self, instance): # noqa: ARG002 + """Get course availability""" + + # This is a hard coded value because the consumers of the API need this field. + # In an ideal situation the availability could be "dated" or "anytime". + # Since all the courses in xPRO are dated so we will not check for "self paced" + # courses to determine if the course could be "anytime" + return "dated" def get_url(self, instance): """Get CMS Page URL for the course""" @@ -217,6 +227,7 @@ class Meta: "credits", "is_external", "platform", + "availability", ] @@ -280,6 +291,16 @@ class ProgramSerializer(serializers.ModelSerializer): video_url = serializers.SerializerMethodField() credits = serializers.SerializerMethodField() platform = serializers.SerializerMethodField() + availability = serializers.SerializerMethodField() + + def get_availability(self, instance): # noqa: ARG002 + """Get program availability""" + + # This is a hard coded value because the consumers of the API need this field. + # In an ideal situation the availability could be "dated" or "anytime". + # Since all the courses in xPRO are dated so we will not check for "self paced" + # courses to determine if the course could be "anytime" + return "dated" def get_courses(self, instance): """Serializer for courses""" @@ -411,6 +432,7 @@ class Meta: "credits", "is_external", "platform", + "availability", ]