def teamset_is_public_or_user_is_on_team_in_teamset(user, course_module, teamset_id): """ The only users who should be able to see private_managed teamsets or recieve any information about them at all from the API are: - Course staff - Users who are enrolled in a team in a private_managed teamset course_module is passed in because almost universally where we'll be calling this, we will already need to have looked up the course from modulestore to make sure that the topic we're interested in exists in the course. """ teamset = course_module.teams_configuration.teamsets_by_id[teamset_id] if teamset.teamset_type != TeamsetType.private_managed: return True return CourseTeamMembership.user_in_team_for_teamset(user, course_module.id, topic_id=teamset_id)
def test_user_in_team_for_course_teamset(self, username, course_id, teamset_id, expected_value): user = getattr(self, username) assert CourseTeamMembership.user_in_team_for_teamset( user, course_id, teamset_id) == expected_value