Example #1
0
 def is_enrollment_protection_for_existing_team_matches_user(self, user, team_name, teamset_id):
     """
     Applies only to existing teams.
     Returns True if no violations
     False if there is a mismatch
     """
     try:
         team = self.existing_course_teams[(team_name, teamset_id)]
         return user_protection_status_matches_team(user, team)
     except KeyError:
         return True
Example #2
0
    def add_user(self, user):
        """Adds the given user to the CourseTeam."""
        from lms.djangoapps.teams.api import user_protection_status_matches_team

        if not CourseEnrollment.is_enrolled(user, self.course_id):
            raise NotEnrolledInCourseForTeam
        if CourseTeamMembership.user_in_team_for_course(
                user, self.course_id, self.topic_id):
            raise AlreadyOnTeamInCourse
        if not user_protection_status_matches_team(user, self):
            raise AddToIncompatibleTeamError
        return CourseTeamMembership.objects.create(user=user, team=self)