-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
37 lines (34 loc) · 1.13 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from django.http import JsonResponse, HttpResponse
from django.shortcuts import render, redirect
from django.core.urlresolvers import reverse
from .IltOAuthClient import IltOAuthClient as IOC
def run(request):
if 'token' in request.GET and request.GET['token']:
data = IOC.getData(request.GET['token'])
if not data:
return redirect(reverse('ilt_client:failed'))
else:
request.session['user_files'] = data
if 'redirect' in request.session and request.session['redirect']:
redirect_local_url = request.session['redirect']
del request.session['redirect']
return redirect(redirect_local_url)
else:
return redirect('/')
else:
return redirect(IOC.ilt_redirect_url)
def show(request):
if 'user_files' in request.session:
return JsonResponse(request.session['user_files'])
else:
return HttpResponse('user_files not defined')
from .config import *
def getData_failed(request):
config = {
'REDIRECT_URL': REDIRECT_URL,
'HOST_URL' : HOST_URL,
'CLIENT_KEY' : CLIENT_KEY,
'CLIENT_SECRET' : CLIENT_SECRET,
'SCOPE' : SCOPE,
}
return render(request, 'ilt_client/getData_failed.html', {'config' : config})