Skip to content

Commit

Permalink
refactor: address PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Feb 19, 2024
1 parent 7276c8d commit fa66d6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cms/djangoapps/contentstore/rest_api/v2/serializers/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@


class UnsucceededCourseSerializerV2(serializers.Serializer):
"""Serializer for unsucceeded course"""
"""Serializer for unsucceeded course."""

display_name = serializers.CharField()
course_key = CourseKeyField()
org = serializers.CharField()
Expand Down Expand Up @@ -52,12 +53,16 @@ def get_url(self, obj):
return reverse_course_url('course_handler', obj.id)

def get_is_active(self, obj):
"""Check if the course is active."""
"""Get whether the course is active or not."""
return not obj.has_ended()


class CourseHomeTabSerializerV2(serializers.Serializer):
"""Serializer for course home tab V2 with unsucceeded courses and in process course actions."""

courses = CourseCommonSerializerV2(required=False, many=True)
in_process_course_actions = UnsucceededCourseSerializerV2(many=True, required=False, allow_null=True)
in_process_course_actions = UnsucceededCourseSerializerV2(
many=True,
required=False,
allow_null=True
)
3 changes: 3 additions & 0 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,9 @@ def format_in_process_course_view(uca):
def get_course_context_v2(request):
"""Get context of the homepage course tab from the Studio Home."""

# Importing here to avoid circular imports:
# ImportError: cannot import name 'reverse_course_url' from partially initialized module
# 'cms.djangoapps.contentstore.utils' (most likely due to a circular import)
from cms.djangoapps.contentstore.views.course import (
get_courses_accessible_to_user_v2,
ENABLE_GLOBAL_STAFF_OPTIMIZATION,
Expand Down

0 comments on commit fa66d6c

Please sign in to comment.