summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tbc/templates/tbc/confirm-details.html2
-rw-r--r--tbc/templates/tbc/update-code.html7
-rw-r--r--tbc/templatetags/__init__.py0
-rw-r--r--tbc/templatetags/tags.py11
-rwxr-xr-xtbc/views.py20
5 files changed, 26 insertions, 14 deletions
diff --git a/tbc/templates/tbc/confirm-details.html b/tbc/templates/tbc/confirm-details.html
index 96393ac..904c8c4 100644
--- a/tbc/templates/tbc/confirm-details.html
+++ b/tbc/templates/tbc/confirm-details.html
@@ -8,7 +8,7 @@
</div>
<div class="modal-body">
<p>You are submitting codes for the book <br> <b>{{ book.title }} by {{ book.author }}</b>.
- <br>Kindly verify the book details &amp; <b>enter the number of chapters</b> you will submit the codes for.</p>
+ <br>Kindly verify the book details &amp; <b>enter/edit the number of chapters</b> you want to submit the codes for.</p>
<p>Note: Consider only those chapters which have solved examples</p></p>
</div>
<div class="modal-footer">
diff --git a/tbc/templates/tbc/update-code.html b/tbc/templates/tbc/update-code.html
index 536617b..ec1bbc0 100644
--- a/tbc/templates/tbc/update-code.html
+++ b/tbc/templates/tbc/update-code.html
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
+{% load tags %}
{% block script %}
<script src="/static/js/jquery.js" type="text/javascript"></script>
<script>
@@ -57,9 +58,9 @@ function validate_content()
<p>Upload the corrected IPython Notebooks & screen shots.</p>
<form action="/submit-code/" method=POST enctype="multipart/form-data">
{% csrf_token %}
- {% for chapter in chapters %}
- <input class="chapters" type=text id=chapter{{forloop.counter}} name=chapter{{forloop.counter}} value="{{ chapter.name }}">
- <input type=file name=notebook{{forloop.counter}} id=notebook{{forloop.counter}}>
+ {% for i in no_notebooks %}
+ <input class="chapters" type=text id=chapter{{i}} name=chapter{{i}} value="{{ chapters|lookup:i }}">
+ <input type=file name=notebook{{i}} id=notebook{{i}}>
{% endfor %}
<br>
<hr>
diff --git a/tbc/templatetags/__init__.py b/tbc/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tbc/templatetags/__init__.py
diff --git a/tbc/templatetags/tags.py b/tbc/templatetags/tags.py
new file mode 100644
index 0000000..7087b99
--- /dev/null
+++ b/tbc/templatetags/tags.py
@@ -0,0 +1,11 @@
+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+@register.filter
+def lookup(List, i):
+ try:
+ return List[i-1]
+ except IndexError:
+ return "Chapter " + str(i) + " name"
diff --git a/tbc/views.py b/tbc/views.py
index 2c27845..35fa537 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -781,15 +781,6 @@ def ConfirmBookDetails(request):
except:
return HttpResponseRedirect('/?no_book_alloted=true')
book_to_update = Book.objects.get(id=proposal.accepted.id)
- if proposal.status == "codes disapproved":
- chapters = Chapters.objects.filter(book=book_to_update)
- screen_shots = ScreenShots.objects.filter(book=book_to_update)
- context.update(csrf(request))
- context['book'] = book_to_update
- context['chapters'] = chapters
- context['screenshots'] = screen_shots
- context['no_notebooks'] = book_to_update.no_chapters
- return render_to_response('tbc/update-code.html', context)
if request.method == 'POST':
book_form = BookForm(request.POST, instance=book_to_update)
if book_form.is_valid():
@@ -799,6 +790,15 @@ def ConfirmBookDetails(request):
context.update(csrf(request))
context['form'] = book_form
add_log(current_user, book_to_update, CHANGE, 'Book updated', proposal.id)
+ if proposal.status == "codes disapproved":
+ chapters = Chapters.objects.filter(book=book_to_update)
+ screen_shots = ScreenShots.objects.filter(book=book_to_update)
+ context.update(csrf(request))
+ context['book'] = book_to_update
+ context['chapters'] = chapters
+ context['screenshots'] = screen_shots
+ context['no_notebooks'] = [i for i in range(1, book_to_update.no_chapters+1)]
+ return render_to_response('tbc/update-code.html', context)
return HttpResponseRedirect('/submit-code/')
else:
book_form = BookForm()
@@ -887,7 +887,7 @@ def SubmitCode(request):
' has been submitted on the Python TBC interface.'
add_log(user, curr_book, CHANGE, 'Chapters and Screenshots added',
curr_proposal.id, chat=log_chat)
- email_send(book.reviewer.email, subject, message)
+ email_send(curr_book.reviewer.email, subject, message)
return HttpResponseRedirect('/?up=done')
else:
context.update(csrf(request))