fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add publication options: delay, beta
[redakcja.git]
/
apps
/
apiclient
/
views.py
diff --git
a/apps/apiclient/views.py
b/apps/apiclient/views.py
index
f851590
..
fb3f507
100644
(file)
--- a/
apps/apiclient/views.py
+++ b/
apps/apiclient/views.py
@@
-7,17
+7,17
@@
import oauth2
from apiclient.models import OAuthConnection
from apiclient import wl_consumer
from apiclient.models import OAuthConnection
from apiclient import wl_consumer
-from apiclient.settings import
(WL_REQUEST_TOKEN_URL, WL_ACCESS_TOKEN_URL,
- WL_AUTHORIZE_URL)
+from apiclient.settings import
WL_REQUEST_TOKEN_URL, WL_ACCESS_TOKEN_URL, WL_AUTHORIZE_URL
+from apiclient.settings import BETA_REQUEST_TOKEN_URL, BETA_ACCESS_TOKEN_URL, BETA_AUTHORIZE_URL
@login_required
@login_required
-def oauth(request):
+def oauth(request
, beta=False
):
if wl_consumer is None:
return HttpResponse("OAuth consumer not configured.")
client = oauth2.Client(wl_consumer)
if wl_consumer is None:
return HttpResponse("OAuth consumer not configured.")
client = oauth2.Client(wl_consumer)
- resp, content = client.request(WL_REQUEST_TOKEN_URL)
+ resp, content = client.request(WL_REQUEST_TOKEN_URL
if not beta else BETA_REQUEST_TOKEN_URL
)
if resp['status'] != '200':
raise Exception("Invalid response %s." % resp['status'])
if resp['status'] != '200':
raise Exception("Invalid response %s." % resp['status'])
@@
-31,16
+31,16
@@
def oauth(request):
conn.save()
url = "%s?oauth_token=%s&oauth_callback=%s" % (
conn.save()
url = "%s?oauth_token=%s&oauth_callback=%s" % (
- WL_AUTHORIZE_URL
,
+ WL_AUTHORIZE_URL
if not beta else BETA_AUTHORIZE_URL,
request_token['oauth_token'],
request_token['oauth_token'],
- request.build_absolute_uri(reverse("
users_oauth
_callback")),
+ request.build_absolute_uri(reverse("
apiclient_oauth_callback" if not beta else "apiclient_beta
_callback")),
)
return HttpResponseRedirect(url)
@login_required
)
return HttpResponseRedirect(url)
@login_required
-def oauth_callback(request):
+def oauth_callback(request
, beta=False
):
if wl_consumer is None:
return HttpResponse("OAuth consumer not configured.")
if wl_consumer is None:
return HttpResponse("OAuth consumer not configured.")
@@
-49,7
+49,7
@@
def oauth_callback(request):
token = oauth2.Token(conn.token, conn.token_secret)
token.set_verifier(oauth_verifier)
client = oauth2.Client(wl_consumer, token)
token = oauth2.Token(conn.token, conn.token_secret)
token.set_verifier(oauth_verifier)
client = oauth2.Client(wl_consumer, token)
- resp, content = client.request(WL_ACCESS_TOKEN_URL, method="POST")
+ resp, content = client.request(WL_ACCESS_TOKEN_URL
if not beta else BETA_ACCESS_TOKEN_URL
, method="POST")
access_token = dict(cgi.parse_qsl(content))
conn.access = True
access_token = dict(cgi.parse_qsl(content))
conn.access = True