Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions csm_web/scheduler/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class SectionSerializer(serializers.ModelSerializer):
user_role = serializers.SerializerMethodField()
associated_profile_id = serializers.SerializerMethodField()
course_restricted = serializers.BooleanField(source="mentor.course.is_restricted")
num_students_waitlisted = serializers.SerializerMethodField()

def get_num_students_enrolled(self, obj):
"""Retrieve the number of students enrolled in the section"""
Expand All @@ -276,6 +277,14 @@ def get_num_students_enrolled(self, obj):
else obj.current_student_count
)

def get_num_students_waitlisted(self, obj):
"""Retrieve the number of students waitlisted for the section"""
return (
obj.num_waitlisted_annotation
if hasattr(obj, "num_waitlisted_annotation")
else obj.current_waitlist_count
)

def user_associated_profile(self, obj):
"""Retrieve the user profile associated with the section"""
user = self.context.get("request") and self.context.get("request").user
Expand Down Expand Up @@ -319,6 +328,7 @@ class Meta:
"course_title",
"course_restricted",
"waitlist_capacity",
"num_students_waitlisted",
)


Expand Down