summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhardythe12015-03-05 17:10:06 +0530
committerhardythe12015-03-05 17:10:06 +0530
commitd6e7f2e1e0e5bc7bd5f222c4eac71dbaf4875c84 (patch)
treee16b0fde93fb089b84b80e69e7a026ff377f5330
parent5669ecb3f9a7d3c16fbd4bd00b7b448fbb275181 (diff)
downloadPython-TBC-Interface-d6e7f2e1e0e5bc7bd5f222c4eac71dbaf4875c84.tar.gz
Python-TBC-Interface-d6e7f2e1e0e5bc7bd5f222c4eac71dbaf4875c84.tar.bz2
Python-TBC-Interface-d6e7f2e1e0e5bc7bd5f222c4eac71dbaf4875c84.zip
changed to clean URL for convert notebook
-rw-r--r--PythonTBC/settings.py10
-rw-r--r--tbc/models.py4
-rw-r--r--tbc/templates/tbc/book-details.html4
-rw-r--r--tbc/templates/tbc/book-review-details.html4
-rwxr-xr-xtbc/views.py10
5 files changed, 17 insertions, 15 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py
index f7cab4e..a225d8a 100644
--- a/PythonTBC/settings.py
+++ b/PythonTBC/settings.py
@@ -56,12 +56,14 @@ USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
-MEDIA_ROOT = join(PROJDIR, '../tbc/static/uploads')
+MEDIA_ROOT = '/home/hardik/Virtualenvs/PythonTBC/Python-Textbook-Companions'
+#MEDIA_ROOT = join(PROJDIR, '../tbc/static/uploads')
+#print PROJDIR
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
-MEDIA_URL = '/tbc/static/uploads/'
+MEDIA_URL = '/Python-Textbook-Companions/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
@@ -79,6 +81,7 @@ STATICFILES_DIRS = (
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
join(PROJDIR, '../tbc/static'),
+ '/home/hardik/PythonTBC'
)
# List of finder classes that know how to find static files in
@@ -120,7 +123,8 @@ TEMPLATE_DIRS = (
# Don't forget to use absolute paths, not relative paths.
join(PROJDIR, '../tbc/templates'),
join(PROJDIR, '../tbc/static/uploads'),
- join(PROJDIR, '../comments/templates')
+ join(PROJDIR, '../comments/templates'),
+ '/home/hardik/Virtualenvs/PythonTBC/Python-Textbook-Companions'
)
INSTALLED_APPS = (
'django.contrib.auth',
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, {})