Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
MEI-9862 return users organization groups in user and course api (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
mudassir-hafeez authored Aug 20, 2021
1 parent 0d23dee commit d0acf17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions edx_solutions_api_integration/courses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ def get_serializer_context(self):
"is_staff",
"last_login",
"attributes",
"organization_groups",
]

active_attributes = []
Expand Down
15 changes: 15 additions & 0 deletions edx_solutions_api_integration/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ class UserSerializer(DynamicFieldsModelSerializer):
grades = serializers.SerializerMethodField('get_user_grades')
attributes = serializers.SerializerMethodField('get_organization_attributes')
course_groups = serializers.SerializerMethodField('get_user_course_groups')
organization_groups = serializers.SerializerMethodField('get_user_organization_groups')

def get_user_organization_groups(self, user):
"""
Return a list of user organization groups.
"""
organization_groups = [
{
'organization_id': group.organization_id,
'group_id': group.group_id,

} for group in user.organizationgroupuser_set.all()
]
return organization_groups

def get_user_course_groups(self, user):
"""Return a list of course groups of the users, optionally filtered by course id."""
Expand Down Expand Up @@ -149,6 +163,7 @@ class Meta:
"grades",
"attributes",
"course_groups",
"organization_groups",
)
read_only_fields = ("id", "email", "username")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='api-integration',
version='5.0.4',
version='5.0.5',
description='RESTful api integration for edX platform',
long_description=open('README.rst').read(),
author='edX',
Expand Down

0 comments on commit d0acf17

Please sign in to comment.