Commit f4c08bbc by Clinton Blackburn Committed by Clinton Blackburn

Fixed Studio API bug with course team updates

The org field is now set on the CourseAccessRole object, since Studio expects that value to be present.

LEARNER-2469
parent 5139b570
......@@ -60,6 +60,7 @@ class CourseRunTeamSerializerMixin(serializers.Serializer):
for member in team:
CourseAccessRole.objects.update_or_create(
course_id=instance.id,
org=instance.id.org,
user=User.objects.get(username=member['user']),
defaults={'role': member['role']}
)
......
......@@ -37,7 +37,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
def assert_access_role(self, course_run, user, role):
# An error will be raised if the endpoint did not create the role
CourseAccessRole.objects.get(course_id=course_run.id, user=user, role=role)
CourseAccessRole.objects.get(course_id=course_run.id, org=course_run.id.org, user=user, role=role)
def assert_course_access_role_count(self, course_run, expected):
assert CourseAccessRole.objects.filter(course_id=course_run.id).count() == expected
......@@ -143,9 +143,9 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
# The request should only update or create new team members
existing_user = UserFactory()
CourseAccessRole.objects.create(course_id=course_run.id, role=role, user=existing_user)
CourseAccessRole.objects.create(course_id=course_run.id, org=course_run.id.org, role=role, user=existing_user)
new_user = UserFactory()
CourseAccessRole.objects.create(course_id=course_run.id, role=role, user=new_user)
CourseAccessRole.objects.create(course_id=course_run.id, org=course_run.id.org, role=role, user=new_user)
assert CourseAccessRole.objects.filter(course_id=course_run.id).count() == 2
data = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment