Skip to content

Commit

Permalink
Add courses where user is teacher to api
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelGusse committed Mar 5, 2024
1 parent b31e686 commit 6203403
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions userprofile/api/full_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class UserSerializer(UserBriefSerializer):
last_name = serializers.CharField(source='user.last_name')
email = serializers.CharField(source='user.email')
enrolled_courses = SerializerMethodField()
staff_courses = SerializerMethodField()

class Meta(UserBriefSerializer.Meta):
fields = (
'enrolled_courses',
'staff_courses',
'student_id',
'full_name',
'first_name',
Expand All @@ -36,3 +38,8 @@ def get_enrolled_courses(self, obj):
courses = CourseInstance.objects.get_enrolled(obj)
serializer = CourseBriefSerializer(instance=courses, many=True, context=self.context)
return serializer.data

def get_staff_courses(self, obj):
staff_courses = CourseInstance.objects.get_teaching(obj)
serializer = CourseBriefSerializer(instance=staff_courses, many=True, context=self.context)
return serializer.data

0 comments on commit 6203403

Please sign in to comment.