summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrashant S2019-11-05 10:15:27 +0530
committerGitHub2019-11-05 10:15:27 +0530
commit3400306a95e3b3c5b648228bed05cd1276f8b9f7 (patch)
tree9b6e064fd50a66edc61b8ee46f968c664a93968e
parent7bc92d7aa89c9431eaf9556199f2e04553ca1bd7 (diff)
parent2de06c38bceee5b92d54fadfd619e2d206917b09 (diff)
downloadR_on_Cloud_Web_Interface-3400306a95e3b3c5b648228bed05cd1276f8b9f7.tar.gz
R_on_Cloud_Web_Interface-3400306a95e3b3c5b648228bed05cd1276f8b9f7.tar.bz2
R_on_Cloud_Web_Interface-3400306a95e3b3c5b648228bed05cd1276f8b9f7.zip
Merge pull request #6 from prashantsinalkar/master
fixed category display issue on load
-rw-r--r--website/views.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/website/views.py b/website/views.py
index 3268ad0..c09821c 100644
--- a/website/views.py
+++ b/website/views.py
@@ -240,12 +240,24 @@ def index(request):
params=[chapter_id[0]])
preference_id = cursor.fetchone()
with connections['r'].cursor() as cursor:
- cursor.execute(GET_TBC_PREFERENCE_DETAIL_CATEGORY_SQL,
+ rows_count = cursor.execute(GET_TBC_PREFERENCE_DETAIL_CATEGORY_SQL,
params=[preference_id[0]])
- books_detail = cursor.fetchone()
- books = get_books(books_detail[1])
- maincat_id = books_detail[0]
- subcat_id = books_detail[1]
+ if rows_count > 0:
+ books_detail = cursor.fetchone()
+ books = get_books(books_detail[1])
+ maincat_id = books_detail[0]
+ subcat_id = books_detail[1]
+ else:
+ catg_all = catg()
+ context = {
+ 'catg': catg_all,
+ 'err_msg': """This book is not supported by R on Cloud."""
+ """ You are redirected to home page."""
+ }
+ context['api_url_upload'] = API_URL_UPLOAD
+ context['reset_req_url'] = API_URL_RESET
+ template = loader.get_template('index.html')
+ return HttpResponse(template.render(context, request))
with connections['r'].cursor() as cursor:
cursor.execute(GET_TBC_EXAMPLE_FILE_SQL,
@@ -291,10 +303,11 @@ def index(request):
.order_by('subcategory_id')
categ_all = TextbookCompanionCategoryList.objects.using('r')\
.filter(~Q(category_id=0)).order_by('maincategory')
- if len(list([ex_views_count[0]])) == 0:
- ex_views_count = 0
- else:
- ex_views_count = ex_views_count[0]
+ ex_views_count = 0
+ #if len(list([ex_views_count[0]])) == 0:
+ # ex_views_count = 0
+ #else:
+ # ex_views_count = ex_views_count[0]
context = {
'catg': categ_all,
'subcatg': subcateg_all,
@@ -347,8 +360,6 @@ def reset(request):
for key, value in list(request.session.items()):
if key != 'user_id':
del request.session[key]
- print('{} => {}'.format(key, value))
- print("done----")
response = {"data" : "ok"}
return HttpResponse(simplejson.dumps(response),
content_type='application/json')