Пример #1
0
    def test_can_join_team(self):
        user, team, outsider = self.user, self.team, self.outsider

        # Current members can't join the team.
        for r in [ROLE_CONTRIBUTOR, ROLE_MANAGER, ROLE_ADMIN, ROLE_OWNER]:
            with self.role(r):
                self.assertFalse(can_join_team(team, user))

        # Outsiders can join the team.
        team.membership_policy = Team.OPEN
        team.save()
        self.assertTrue(can_join_team(team, outsider))

        # But not if the team requires invitation/application.
        for policy in [
                Team.APPLICATION, Team.INVITATION_BY_ALL,
                Team.INVITATION_BY_MANAGER, Team.INVITATION_BY_ADMIN
        ]:
            team.membership_policy = policy
            team.save()
            self.assertFalse(can_join_team(team, outsider))
Пример #2
0
 def check_join_permissions(self, role):
     if not (role == TeamMember.ROLE_CONTRIBUTOR and
             team_permissions.can_join_team(self.team, self.request.user)):
         raise PermissionDenied()