Connecting WL + publishing author.
[redakcja.git] / src / apiclient / views.py
index 666ef48..e43ae0c 100644 (file)
@@ -6,6 +6,7 @@ from urllib.parse import parse_qsl
 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
@@ -60,4 +61,11 @@ def oauth_callback(request, beta=False):
     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'))