diff options
author | Prashant S | 2019-12-19 11:34:17 +0530 |
---|---|---|
committer | GitHub | 2019-12-19 11:34:17 +0530 |
commit | 70b858a38b53c23bca3c905822f70dc37a14dbb9 (patch) | |
tree | a5fda278294710b2e6e44a34d7aed44cb4bbe4d8 /website/views.py | |
parent | ced78ae9698f0c42e018f87f5dc5bef51de85be7 (diff) | |
parent | f9ce1e01ab2f98fbcc40bfdd3ec9d70b9de15ac6 (diff) | |
download | R_on_Cloud_Web_Interface-70b858a38b53c23bca3c905822f70dc37a14dbb9.tar.gz R_on_Cloud_Web_Interface-70b858a38b53c23bca3c905822f70dc37a14dbb9.tar.bz2 R_on_Cloud_Web_Interface-70b858a38b53c23bca3c905822f70dc37a14dbb9.zip |
Merge pull request #8 from prashantsinalkar/master
added api connection check call
Diffstat (limited to 'website/views.py')
-rw-r--r-- | website/views.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/website/views.py b/website/views.py index d6646f4..e554ef4 100644 --- a/website/views.py +++ b/website/views.py @@ -3,7 +3,8 @@ from django.http import HttpResponse from django.template import loader import requests import uuid -from R_on_Cloud.config import (API_URL_UPLOAD, API_URL_RESET, AUTH_KEY) +from R_on_Cloud.config import (API_URL_UPLOAD, API_URL_RESET, AUTH_KEY, + API_URL_SERVER) from website.models import * from django.db.models import Q import json as simplejson @@ -83,6 +84,7 @@ def index(request): user_id = uuid.uuid4() context['api_url_upload'] = API_URL_UPLOAD context['reset_req_url'] = API_URL_RESET + context['api_url'] = API_URL_SERVER book_id = request.GET.get('book_id') user = request.user if not 'user_id' in request.session: @@ -140,6 +142,7 @@ def index(request): 'api_url_upload': API_URL_UPLOAD, 'user_id': request.session['user_id'], 'key': AUTH_KEY, + 'api_url': API_URL_SERVER, } template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) @@ -172,6 +175,7 @@ def index(request): } context['api_url_upload'] = API_URL_UPLOAD context['reset_req_url'] = API_URL_RESET + context['api_url'] = API_URL_SERVER template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) @@ -212,6 +216,7 @@ def index(request): } context['api_url_upload'] = API_URL_UPLOAD context['reset_req_url'] = API_URL_RESET + context['api_url'] = API_URL_SERVER template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) @@ -241,7 +246,7 @@ def index(request): preference_id = cursor.fetchone() with connections['r'].cursor() as cursor: rows_count = cursor.execute(GET_TBC_PREFERENCE_DETAIL_CATEGORY_SQL, - params=[preference_id[0]]) + params=[preference_id[0]]) if rows_count > 0: books_detail = cursor.fetchone() books = get_books(books_detail[1]) @@ -252,10 +257,11 @@ def index(request): context = { 'catg': catg_all, 'err_msg': """This book is not supported by R on Cloud.""" - """ You are redirected to home page.""" + """ You are redirected to home page.""" } context['api_url_upload'] = API_URL_UPLOAD context['reset_req_url'] = API_URL_RESET + context['api_url'] = API_URL_SERVER template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) @@ -296,6 +302,7 @@ def index(request): """ scilab on cloud.""" } context['api_url_upload'] = API_URL_UPLOAD + context['api_url'] = API_URL_SERVER template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) subcateg_all = get_subcategories(maincat_id) @@ -330,6 +337,7 @@ def index(request): # context['user'] = user context['api_url_upload'] = API_URL_UPLOAD context['reset_req_url'] = API_URL_RESET + context['api_url'] = API_URL_SERVER template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) @@ -359,11 +367,11 @@ def reset(request): for key, value in list(request.session.items()): if key != 'user_id': del request.session[key] - response = {"data" : "ok"} + response = {"data": "ok"} return HttpResponse(simplejson.dumps(response), - content_type='application/json') + content_type='application/json') except KeyError: pass - response = {"data" : "ok"} + response = {"data": "ok"} return HttpResponse(simplejson.dumps(response), content_type='application/json') |