from django.contrib.auth.decorators import login_required
from django.urls import reverse
from django.http import HttpResponseRedirect, HttpResponse
+from django.views.decorators.http import require_POST
import oauth2
from apiclient.models import OAuthConnection
conn.token_secret = access_token['oauth_token_secret']
conn.save()
- return HttpResponseRedirect('/')
+ return HttpResponseRedirect(reverse('documents_user'))
+
+
+@login_required
+@require_POST
+def disconnect(request):
+ request.user.oauthconnection_set.filter(beta=False).delete()
+ return HttpResponseRedirect(reverse('documents_user'))