Пример #1
0
    def test_can_change_team_settings(self):
        # Only admins and owners can view/change the settings tab, so this one
        # is pretty simple.
        user = self.user
        team = self.team

        for r in [ROLE_ADMIN, ROLE_OWNER]:
            with self.role(r):
                self.assertTrue(can_change_team_settings(team, user))

        with self.role(ROLE_ADMIN, self.test_project):
            self.assertFalse(can_change_team_settings(team, user))

        for r in [ROLE_MANAGER, ROLE_CONTRIBUTOR]:
            with self.role(r):
                self.assertFalse(can_change_team_settings(team, user))
Пример #2
0
 def perform_update(self, serializer):
     if not team_permissions.can_change_team_settings(
             serializer.instance, self.request.user):
         raise PermissionDenied()
     team = serializer.instance
     initial_settings = team.get_settings()
     with transaction.atomic():
         serializer.save()
         team.handle_settings_changes(self.request.user, initial_settings)
Пример #3
0
def already_linked_message(user, other_account):
    if other_account.user is not None:
        return fmt(_('That youtube account has already been linked '
                     'to the user %(username)s.'),
                   username=other_account.user.username)

    if can_change_team_settings(other_account.team, user):
        settings_link = reverse('teams:settings_externalsites', kwargs={
            'slug': other_account.team.slug,
        })
        return fmt(_('That youtube account has already been linked '
                     'to the %(team)s team '
                     '(<a href="%(link)s">view settings page</a>).'),
                   team=other_account.team,
                   link=settings_link)
    else:
        return fmt(_('That youtube account has already been linked '
                     'to the %(team)s team.'),
                   team=other_account.team)
Пример #4
0
 def perform_update(self, serializer):
     if not team_permissions.can_change_team_settings(
             serializer.instance, self.request.user):
         raise PermissionDenied()
     serializer.save()