From d6e7f2e1e0e5bc7bd5f222c4eac71dbaf4875c84 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Thu, 5 Mar 2015 17:10:06 +0530 Subject: changed to clean URL for convert notebook --- tbc/models.py | 4 ++-- tbc/templates/tbc/book-details.html | 4 ++-- tbc/templates/tbc/book-review-details.html | 4 ++-- tbc/views.py | 10 ++++------ 4 files changed, 10 insertions(+), 12 deletions(-) (limited to 'tbc') diff --git a/tbc/models.py b/tbc/models.py index 5c052a1..74419e4 100644 --- a/tbc/models.py +++ b/tbc/models.py @@ -56,11 +56,11 @@ BOOK_PREFERENCE = (("book1","1st Book"), def get_notebook_dir(instance, filename): - return '%s/%s/%s' % (instance.book.contributor, instance.book.title.replace(' ', '_'), filename.replace(' ', '_')) + return '%s/%s' % (instance.book.title.replace(' ', '_'), filename.replace(' ', '_')) def get_image_dir(instance, filename): - return '%s/%s/screenshots/%s' % (instance.book.contributor, instance.book.title.replace(' ', '_'), filename.replace(' ', '_')) + return '%s/screenshots/%s' % (instance.book.title.replace(' ', '_'), filename.replace(' ', '_')) def get_sample_dir(instance, filename): diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index dc8c272..1c9bab7 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -20,9 +20,9 @@ function redirectToIpynb(notebook) {% for image in images %}
{% if image.chapters_set.get.notebook %} - + {% else %} - + {% endif %}

{{ image.caption }}

diff --git a/tbc/templates/tbc/book-review-details.html b/tbc/templates/tbc/book-review-details.html index e546220..33401d5 100644 --- a/tbc/templates/tbc/book-review-details.html +++ b/tbc/templates/tbc/book-review-details.html @@ -6,9 +6,9 @@ {% for image in images %}
{% if image.chapters_set.get.notebook %} - + {% else %} - + {% endif %}

{{ image.caption }}

diff --git a/tbc/views.py b/tbc/views.py index deb5123..2d246ed 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -9,6 +9,7 @@ from django.contrib.admin.models import CHANGE from django.contrib.auth.decorators import login_required from models import * from tbc.forms import * +import local import os import zipfile import StringIO @@ -1151,8 +1152,7 @@ def BrowseBooks(request): def ConvertNotebook(request, notebook_path=None): context = {} - path = os.path.abspath(os.path.dirname(__file__)) - path = path+"/static/uploads/" + path = local.path path = path+notebook_path notebook_name = path.split("/")[-1:] notebook_name = notebook_name[0].split(".")[0] @@ -1160,13 +1160,11 @@ def ConvertNotebook(request, notebook_path=None): path = "/".join(path)+"/" os.chdir(path) try: - template = path.split("/")[8:] - template = "/".join(template)+notebook_name+".html" + template = path+notebook_name+".html" return render_to_response(template, {}) except: os.popen("ipython nbconvert --to html \""+path+notebook_name+".ipynb\"") - template = path.split("/")[8:] - template = "/".join(template)+notebook_name+".html" + template = path+notebook_name+".html" return render_to_response(template, {}) -- cgit From 4f11d251ce6922f3e6091b4d588b2a640d58ef5d Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Fri, 13 Mar 2015 14:59:20 +0530 Subject: updated img source --- tbc/templates/tbc/book-details.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tbc') diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index 1c9bab7..99c8ba6 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -20,9 +20,9 @@ function redirectToIpynb(notebook) {% for image in images %}
{% if image.chapters_set.get.notebook %} - + {% else %} - + {% endif %}

{{ image.caption }}

-- cgit From 707af515ef317adc74d6ad9f0c912eb598c5ff9f Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Fri, 13 Mar 2015 15:21:58 +0530 Subject: updated new path to clean the URLs --- tbc/templates/base.html | 2 +- tbc/views.py | 41 ++++++++++++++++++----------------------- 2 files changed, 19 insertions(+), 24 deletions(-) (limited to 'tbc') diff --git a/tbc/templates/base.html b/tbc/templates/base.html index d4c3a9e..5d0c844 100755 --- a/tbc/templates/base.html +++ b/tbc/templates/base.html @@ -295,7 +295,7 @@
{% for item in items %}
- +
{{ item.book.title }}
{% endfor %} diff --git a/tbc/views.py b/tbc/views.py index 2d246ed..5b2802c 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -1029,29 +1029,11 @@ def ApproveBook(request, book_id=None): if is_reviewer(request.user): if request.method == 'POST' and request.POST['approve_notify'] == "approve": book = Book.objects.get(id=book_id) - book.approved = True - book.save() - try: - proposal = Proposal.objects.get(accepted=book) - proposal.status = "book completed" - proposal.save() - msg = "Book Approved" - except Proposal.DoesNotExist: - proposal = Proposal() - proposal.user = book.contributor - proposal.accepted = book - proposal.status = "book completed" - proposal.save() - msg = "Old Book Approved" - file_path = os.path.abspath(os.path.dirname(__file__)) - copy_path = "/".join(file_path.split("/")[1:-2]) - copy_path = "/"+copy_path+"/Python-Textbook-Companions/" - file_path = file_path+"/static/uploads/" - directory = file_path+book.contributor.user.first_name - os.chmod(directory, 0777) - os.chdir(directory) + file_path = local.path book_title = book.title.replace(" ", "_") - fp = open(book_title+"/README.txt", 'w') + directory = file_path+book_title + os.chdir(directory) + fp = open(directory+"/README.txt", 'w') fp.write("Contributed By: "+book.contributor.user.first_name+" "+book.contributor.user.last_name+"\n") fp.write("Course: "+book.contributor.course+"\n") fp.write("College/Institute/Organization: "+book.contributor.insti_org+"\n") @@ -1063,7 +1045,20 @@ def ApproveBook(request, book_id=None): fp.write("Isbn: "+book.isbn+"\n") fp.write("Edition: "+book.edition) fp.close() - os.popen("cp -r '"+book_title+"' '"+copy_path+"'") + try: + proposal = Proposal.objects.get(accepted=book) + proposal.status = "book completed" + proposal.save() + msg = "Book Approved" + except Proposal.DoesNotExist: + proposal = Proposal() + proposal.user = book.contributor + proposal.accepted = book + proposal.status = "book completed" + proposal.save() + msg = "Old Book Approved" + book.approved = True + book.save() subject = "Python-TBC: Book Completion" message = """Hi """+book.contributor.user.first_name+""",\n Congratulations !\nThe book - """+book.title+""" is now complete & published.\nPlease visit the link given below to download the forms to be filled to complete the formalities.\nhttp://tbc-python.fossee.in/internship-forms\nThe forms should be duly filled (fill only the sections which are applicable) & submitted at the following address:\nDr. Prabhu Ramachandran,\nDepartment of Aerospace Engineering,\nIIT Bombay, Powai, Mumbai - 400076\nKindly write Python Textbook Companion on top of the envelope.\nIf you already sent the forms then you may kindly ignore this mail.\n\nThank You for your contribution !\nRegards,\n Python TBC Team,\nFOSSEE - IIT Bombay""" -- cgit