diff options
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/models.py | 4 | ||||
-rw-r--r-- | tbc/templates/tbc/book-details.html | 4 | ||||
-rw-r--r-- | tbc/templates/tbc/book-review-details.html | 4 | ||||
-rwxr-xr-x | tbc/views.py | 10 |
4 files changed, 10 insertions, 12 deletions
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 %} <div class ="module-list"> {% if image.chapters_set.get.notebook %} - <a href="{% url 'tbc:ConvertNotebook' image.chapters_set.get.notebook %}"><img src="{% static 'uploads/' %}{{ image.image }}"></a> + <a href="{% url 'tbc:ConvertNotebook' image.chapters_set.get.notebook %}"><img src="{% static '{{ book.title }}' %}{{ image.image }}"></a> {% else %} - <img src="{% static 'uploads/' %}{{ image.image }}"> + <img src="{% static '{{ book.title }}' %}{{ image.image }}"> {% endif %} <center><p style="margin-top:30px;">{{ image.caption }}</p></center> </div> 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 %} <div class ="module-list"> {% if image.chapters_set.get.notebook %} - <a href="{% url 'tbc:ConvertNotebook' image.chapters_set.get.notebook %}"><img src="{% static 'uploads/' %}{{ image.image }}"></a> + <a href="{% url 'tbc:ConvertNotebook' image.chapters_set.get.notebook %}"><img src="{% static 'Python-Textbook-Companions/' %}{{ image.image }}"></a> {% else %} - <img src="{% static 'uploads/' %}{{ image.image }}"> + <img src="{% static 'Python-Textbook-Companions/' %}{{ image.image }}"> {% endif %} <center><p style="margin-top:30px;">{{ image.caption }}</p></center> </div> 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, {}) |