From f60d22247606b536227f9dc9a3d58d2a2919665d Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 21 Apr 2016 17:23:38 +0530 Subject: added login_required decorator --- tbc/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tbc') diff --git a/tbc/views.py b/tbc/views.py index 18e2d4d..1466ff1 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -1415,7 +1415,7 @@ def link_image(request): context['success'] = True return render_to_response('tbc/link_image.html', context, context_instance=ci) -@login_required( login_url= "/admin") +@login_required(login_url="/login/") def admin_tools(request): ci = RequestContext(request) curr_user = request.user -- cgit From 1d6eede612130ae0bb6ea4fa03f60fc71ecbbe3d Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 21 Apr 2016 18:34:46 +0530 Subject: changes in context --- tbc/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tbc') diff --git a/tbc/views.py b/tbc/views.py index 1466ff1..f6e93ae 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -1423,5 +1423,5 @@ def admin_tools(request): if not is_reviewer(curr_user): raise Http404("You are not allowed to view this page") else: - context = {"user":curr_user} - return render_to_response('tbc/admin-tools.html', context, context_instance=ci) + context = {"reviewer":curr_user} + return render_to_response('tbc/admin-tools.html', context, ci) -- cgit From e85df2bdab22c5ca8364683d8839148ff1f3a45d Mon Sep 17 00:00:00 2001 From: mahesh Date: Tue, 26 Apr 2016 14:57:18 +0530 Subject: made changes to convert notebook function --- tbc/views.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'tbc') diff --git a/tbc/views.py b/tbc/views.py index f6e93ae..e866c46 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -1189,7 +1189,6 @@ def BrowseBooks(request): return render_to_response('tbc/browse-books.html', context) - def ConvertNotebook(request, notebook_path=None): """ Checks for the modified time of ipython notebooks and corresponding html page and replaces html page with new one if corresponding ipython notebook has been modified. """ @@ -1198,16 +1197,23 @@ def ConvertNotebook(request, notebook_path=None): path = os.path.join(local.path, notebook_path.strip(".ipynb")) template_html = path+".html" template_ipynb =path+".ipynb" - modified_time_for_html = os.stat(template_html).st_mtime - modified_time_for_ipynb = os.stat(template_ipynb).st_mtime + template_dir = os.path.dirname(path) + + def nbconvert(template_ipynb): + notebook_convert = "ipython nbconvert --to html {0} --FilesWriter.build_directory={1}".format(template_ipynb, template_dir) + subprocess.call (notebook_convert, shell = True) - if os.path.isfile(template_html) and modified_time_for_html > modified_time_for_ipynb: - return render_to_response(template_html, {}) - else: - notebook_convert = "ipython nbconvert --to html %s" % str(template_ipynb) - subprocess.call (notebook_convert) - return render_to_response(template_html, {}) + if os.path.isfile(template_html): + modified_time_for_html = os.stat(template_html).st_mtime + modified_time_for_ipynb = os.stat(template_ipynb).st_mtime + if not modified_time_for_html > modified_time_for_ipynb: + nbconvert(template_ipynb) + + else: + nbconvert(template_ipynb) + + return render_to_response(template_html, context) def CompletedBooks(request): -- cgit