Skip to content

Commit

Permalink
feat: add course and program availability
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanashraf7 committed Aug 8, 2024
1 parent 23e7e54 commit 6018922
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions courses/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -217,6 +227,7 @@ class Meta:
"credits",
"is_external",
"platform",
"availability",
]


Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -411,6 +432,7 @@ class Meta:
"credits",
"is_external",
"platform",
"availability",
]


Expand Down

0 comments on commit 6018922

Please sign in to comment.