diff --git a/lms/djangoapps/django_comment_client/tests/test_utils.py b/lms/djangoapps/django_comment_client/tests/test_utils.py index d6e9940821..76ddf1b7d2 100644 --- a/lms/djangoapps/django_comment_client/tests/test_utils.py +++ b/lms/djangoapps/django_comment_client/tests/test_utils.py @@ -1696,6 +1696,10 @@ class GroupModeratorPermissionsTestCase(ModuleStoreTestCase): """Test utils functionality related to forums "abilities" (permissions) for group moderators""" def _check_condition(user, condition, content): + """ + Mocks check_condition method because is_open and is_team_member_if_applicable must always be true + in order to interact with a thread or comment. + """ return True if condition == 'is_open' or condition == 'is_team_member_if_applicable' else False def setUp(self): @@ -1716,7 +1720,7 @@ class GroupModeratorPermissionsTestCase(ModuleStoreTestCase): # Create four users: group_moderator (who is within the verified enrollment track and in the cohort), # verified_user (who is in the verified enrollment track but not the cohort), # cohorted_user (who is in the cohort but not the verified enrollment track), - # and plain_user (who is neither in the cohort nor the verified enrollment track)x + # and plain_user (who is neither in the cohort nor the verified enrollment track) self.group_moderator = UserFactory(username='group_moderator', email='group_moderator@edx.org') self.group_moderator.id = 1 CourseEnrollmentFactory( diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index ca132c7ec1..a9eee26f58 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -569,14 +569,15 @@ def get_user_group_ids(course_id, content, user=None): content_user_group_id = None user_group_id = None if course_id is not None: + course_discussion_settings = get_course_discussion_settings(course_id) if content.get('username'): try: content_user = get_user_by_username_or_email(content.get('username')) - content_user_group_id = get_group_id_for_user(content_user, get_course_discussion_settings(course_id)) + content_user_group_id = get_group_id_for_user(content_user, course_discussion_settings) except User.DoesNotExist: content_user_group_id = None - user_group_id = get_group_id_for_user(user, get_course_discussion_settings(course_id)) if user else None + user_group_id = get_group_id_for_user(user, course_discussion_settings) if user else None return user_group_id, content_user_group_id @@ -822,7 +823,7 @@ def get_group_id_for_user(user, course_discussion_settings): elif division_scheme == CourseDiscussionSettings.ENROLLMENT_TRACK: partition_service = PartitionService(course_discussion_settings.course_id) group_id = partition_service.get_user_group_id_for_partition(user, ENROLLMENT_TRACK_PARTITION_ID) - # We negate the group_ids from dynamic [partitions so that they will not conflict + # We negate the group_ids from dynamic partitions so that they will not conflict # with cohort IDs (which are an auto-incrementing integer field, starting at 1). return -1 * group_id if group_id is not None else None else: