-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [AXIM-38] Add is_enrolled to Course detail response
- Loading branch information
1 parent
8c9232a
commit 118a200
Showing
6 changed files
with
198 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Serializer for course_info API | ||
""" | ||
|
||
|
||
from common.djangoapps.student.models import CourseEnrollment | ||
from lms.djangoapps.course_api.serializers import CourseDetailSerializer | ||
|
||
|
||
class CourseInfoDetailSerializer(CourseDetailSerializer): | ||
""" | ||
Serializer for Course objects providing additional details about the | ||
course. | ||
This serializer returns more data - 'is_enrolled' user's status. | ||
""" | ||
def to_representation(self, instance): | ||
response = super().to_representation(instance) | ||
|
||
if self.context['request'].user.is_authenticated: | ||
response['is_enrolled'] = CourseEnrollment.is_enrolled(self.context['request'].user, instance.id) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
API_V05 = 'v0.5' | ||
API_V1 = 'v1' | ||
API_V2 = 'v2' | ||
API_V3 = 'v3' | ||
|
||
|
||
def parsed_version(version): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters