Exemplo n.º 1
0
def team_settings_tab(request, team):
    if request.method == 'POST':
        formset = forms.AccountFormset(request.user, team, request.POST)
    else:
        formset = forms.AccountFormset(request.user, team, None)

    if formset.is_valid():
        formset.save()
        if 'remove-youtube-account' in request.POST:
            account = YouTubeAccount.objects.for_owner(team).get(
                id=request.POST['remove-youtube-account'])
            account.delete()
        return redirect(settings_page_redirect_url(team, formset))
    
    if team.is_old_style():
        template_name = 'externalsites/team-settings-tab.html'
    else:
        template_name = 'externalsites/new-team-settings-tab.html'

    return render(request, template_name, {
        'team': team,
        'forms': formset,
        'breadcrumbs': [
            BreadCrumb(team, 'teams:dashboard', team.slug),
            BreadCrumb(_('Settings'), 'teams:settings_basic', team.slug),
            BreadCrumb(_('Integrations')),
        ],
    })
Exemplo n.º 2
0
    def test_forms(self):
        user = UserFactory()
        team = TeamFactory(admin=user)
        account = YouTubeAccountFactory(team=team, id=1)
        account2 = YouTubeAccountFactory(team=team, id=2)
        formset = forms.AccountFormset(user, team)
        assert_equal(
            set(formset.keys()),
            set([
                'brightcovecms',
                'kaltura',
                'add_youtube',
                'add_vimeo',
                'youtube_1',
                'youtube_2',
            ]))
        assert_equal(type(formset['brightcovecms']),
                     forms.BrightcoveCMSAccountForm)
        assert_equal(type(formset['kaltura']), forms.KalturaAccountForm)
        assert_equal(type(formset['add_youtube']), forms.AddYoutubeAccountForm)
        assert_equal(type(formset['youtube_1']), forms.YoutubeAccountForm)
        assert_equal(type(formset['youtube_2']), forms.YoutubeAccountForm)

        assert_equal(set(formset.youtube_forms()),
                     set([formset['youtube_1'], formset['youtube_2']]))
Exemplo n.º 3
0
def team_settings_tab(request, team):
    if request.method == 'POST':
        formset = forms.AccountFormset(request.user, team, request.POST)
    else:
        formset = forms.AccountFormset(request.user, team, None)

    if formset.is_valid():
        formset.save()
        if 'remove-youtube-account' in request.POST:
            account = YouTubeAccount.objects.for_owner(team).get(
                id=request.POST['remove-youtube-account'])
            account.delete()
        return redirect(settings_page_redirect_url(team, formset))

    return render(request, 'externalsites/team-settings-tab.html', {
        'team': team,
        'forms': formset,
    })