summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhardythe12013-11-12 01:07:50 +0530
committerhardythe12013-11-12 01:07:50 +0530
commit4b70f4abf1fc29cc36ebb2179e4ddb4fa5258a95 (patch)
tree17cbcfc47e29920e55f2514f8fb58b5ae6ec368f
parentacd1e3c64ebaa4b3c08758e40b5e9b8486fbd7a5 (diff)
downloadPython-TBC-Interface-4b70f4abf1fc29cc36ebb2179e4ddb4fa5258a95.tar.gz
Python-TBC-Interface-4b70f4abf1fc29cc36ebb2179e4ddb4fa5258a95.tar.bz2
Python-TBC-Interface-4b70f4abf1fc29cc36ebb2179e4ddb4fa5258a95.zip
resolving few bugs
-rw-r--r--tbc/templates/tbc/book-details.html4
-rw-r--r--tbc/templates/tbc/browse-books.html11
-rw-r--r--tbc/views.py31
3 files changed, 18 insertions, 28 deletions
diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html
index 5061ca7..f2912f5 100644
--- a/tbc/templates/tbc/book-details.html
+++ b/tbc/templates/tbc/book-details.html
@@ -13,14 +13,14 @@
<hr>
<ol>
{% for chapter in chapters %}
- <li><a href="https://www.nbviewer.ipython.org/url/fosseeapps.in{% static 'uploads/' %}{{ chapter.notebook }}">{{ chapter.name }}</a>
+ <li><a href="https://nbviewer.ipython.org/url/dev.fossee.in{% static 'uploads/' %}{{ chapter.notebook }}">{{ chapter.name }}</a>
{% endfor %}
</ol>
<hr>
<a href="{% url 'tbc:GetZip' book.id %}" style="float:right;">Download Book as Zip</a>
<table>
<tr><td>Author: &nbsp;&nbsp;<td>{{ book.author }}
-<tr><td>Publisher: &nbsp;&nbsp;<td>{{ book.publisher }}
+<tr><td>Publisher: &nbsp;&nbsp;<td>{{ book.publisher_place }}
<tr><td>ISBN: &nbsp;&nbsp;<td>{{ book.isbn }}
<tr><td>Contributor: &nbsp;&nbsp;<td>{{ book.contributor.user.first_name }} {{ book.contributor.user.last_name }}
<tr><td>Email: &nbsp;&nbsp;<td>{{ book.contributor.user.email }}<br>
diff --git a/tbc/templates/tbc/browse-books.html b/tbc/templates/tbc/browse-books.html
index 6047ce1..0c6924d 100644
--- a/tbc/templates/tbc/browse-books.html
+++ b/tbc/templates/tbc/browse-books.html
@@ -5,13 +5,15 @@
<script type="text/javascript">
function submitCategory()
{
- category = document.getElementById("category").value;
- window.location.replace("/browse-books/"+category);
+ document.forms.browseBooks.submit();
}
</script>
+
{% endblock %}
{% block content %}
+<form name="browseBooks" action="/browse-books/" method=POST enctype="multipart/form-data">
+{% csrf_token %}
<center><select name="category" id="category" onchange="submitCategory();">
<option value="computer science">Computer Science</option>
<option value="chemical engg">Chemical Engg</option>
@@ -24,9 +26,12 @@ function submitCategory()
<div class="row-fluid">
{% for item in items %}
<div class ="module-list">
- <img src="{% static 'uploads/' %}{{ item.image.image }}">
+ <a href="{% url 'tbc:BookDetails' item.book.id %}"><img src="{% static 'uploads/' %}{{ item.image.image }}"></a>
<center><a href="{% url 'tbc:BookDetails' item.book.id %}">{{ item.book.title }}</a></center>
</div>
{% endfor %}
</div>
+<script>
+document.getElementById('category').value = "{{ category }}";
+</script>
{% endblock %}
diff --git a/tbc/views.py b/tbc/views.py
index b229856..6203e22 100644
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -32,12 +32,12 @@ def Home(request):
context['user'] = None
else:
context['user'] = request.user
- books = Book.objects.order_by("-id")[0:6]
- if len(books)>=6:
+ books = Book.objects.filter(approved=True)[0:6]
+ """if len(books)>=6:
context['books'] = books
else:
books = Book.objects.all()
- context['books'] = books
+ context['books'] = books"""
for book in books:
images.append(ScreenShots.objects.filter(book=book)[0])
context['images'] = images
@@ -169,24 +169,6 @@ def ContentUpload(request):
return render_to_response('tbc/upload-content.html', context)
-"""def ImageUpload(request):
- user = request.user
- curr_book = Book.objects.order_by("-id")[0]
- if request.method == 'POST':
- for i in range(1, 4):
- screenshot = ScreenShots()
- screenshot.caption = request.POST['caption'+str(i)]
- screenshot.image = request.FILES['image'+str(i)]
- screenshot.book = curr_book
- screenshot.save()
- return HttpResponse('images uploaded')
- context = {}
- context.update(csrf(request))
- context['user'] = user
- context['no_images'] = [i for i in range(1, 4)]
- return render_to_response('tbc/upload-images.html', context)"""
-
-
def generateZip(book_id):
book = Book.objects.get(id=book_id)
files_to_zip = []
@@ -253,6 +235,7 @@ def ApproveBook(request, book_id=None):
if request.method == 'POST' and request.POST['approve_notify'] == "approve":
book = Book.objects.get(id=book_id)
book.approved = True
+ book.save()
file_path = os.path.abspath(os.path.dirname(__file__))
zip_path = "/".join(file_path.split("/")[1:-2])
zip_path = "/"+zip_path+"/Python-Textbook-Companions/"
@@ -272,11 +255,11 @@ def ApproveBook(request, book_id=None):
fp.write("Edition: "+book.edition)
fp.close()
os.popen("cp -r "+book.title+" "+zip_path)
- os.chdir(zip_path)
+ """os.chdir(zip_path)
os.popen("git add .")
commit_msg = "adding "+book.title
os.popen("git commit -m "+commit_msg)
- os.popen("git push")
+ os.popen("git push")"""
context['user'] = user
return HttpResponse("worked")
elif request.method == 'POST' and request.POST['approve_notify'] == "notify":
@@ -295,6 +278,7 @@ def BrowseBooks(request):
for book in books:
images.append(ScreenShots.objects.filter(book=book)[0])
else:
+ category = 'computer science'
books = Book.objects.filter(category='computer science')
for book in books:
images.append(ScreenShots.objects.filter(book=book)[0])
@@ -304,4 +288,5 @@ def BrowseBooks(request):
obj = {'book':books[i], 'image':images[i]}
book_images.append(obj)
context['items'] = book_images
+ context['category'] = category
return render_to_response('tbc/browse-books.html', context)