summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
authorhardythe12014-10-30 18:23:29 +0530
committerhardythe12014-10-30 18:23:29 +0530
commitea78b786d62021d8d3501313e826053acc231c25 (patch)
tree8348ec6524a66ebf0d21341702c7f0380dfd298d /tbc
parentf604c51131f625e26f1ac95d9464f59b8d89078b (diff)
downloadPython-TBC-Interface-ea78b786d62021d8d3501313e826053acc231c25.tar.gz
Python-TBC-Interface-ea78b786d62021d8d3501313e826053acc231c25.tar.bz2
Python-TBC-Interface-ea78b786d62021d8d3501313e826053acc231c25.zip
adding links to submit book (before automated proposal)
Diffstat (limited to 'tbc')
-rwxr-xr-xtbc/templates/base.html1
-rw-r--r--tbc/templates/tbc/upload-content-old.html72
-rw-r--r--tbc/urls.py2
-rwxr-xr-xtbc/views.py56
4 files changed, 124 insertions, 7 deletions
diff --git a/tbc/templates/base.html b/tbc/templates/base.html
index fbcfb05..a9b005e 100755
--- a/tbc/templates/base.html
+++ b/tbc/templates/base.html
@@ -105,6 +105,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ user.first_name }}<b class="caret"></b></a>
<ul class="dropdown-menu">
+ <li><a href="{% url 'tbc:SubmitBook' %}">Submit Book (OLD)</a></li>
<li><a href="{% url 'tbc:ListAICTE' %}">Submit Proposal</a></li>
<li><a href="{% url 'tbc:SubmitSample' %}">Submit Sample Notebook</a></li>
<li><a href="{% url 'tbc:ConfirmBookDetails' %}">Submit Codes</a></li>
diff --git a/tbc/templates/tbc/upload-content-old.html b/tbc/templates/tbc/upload-content-old.html
new file mode 100644
index 0000000..8b3c692
--- /dev/null
+++ b/tbc/templates/tbc/upload-content-old.html
@@ -0,0 +1,72 @@
+{% extends 'base.html' %}
+
+{% block script %}
+<script>
+function validate_content()
+{
+ no_notebooks = {{ no_notebooks }}.length;
+ for(i=1;i<=no_notebooks;i++)
+ {
+ name = document.getElementById("chapter"+i).value;
+ extension = document.getElementById("notebook"+i).value;
+ extension = extension.split(".");
+ if (extension == "" || name == "")
+ {
+ alert("Chapter names & file fields cannot be empty !!");
+ return false;
+ }
+ if(extension.slice(Math.max(extension.length - 1, 1)) == "ipynb")
+ continue;
+ else
+ alert("Oops !! You can upload only Ipython Notebooks (.ipynb extension)");
+ return false;
+ }
+ for(i=1;i<=3;i++)
+ {
+ caption = document.getElementById("caption"+i).value;
+ extension = document.getElementById("image"+i).value;
+ extension = extension.split(".");
+ if (extension == "" || caption == "")
+ {
+ alert("Captions and file fields cannot be empty");
+ return false;
+ }
+
+ if(extension.slice(Math.max(extension.length - 1, 1)) == "png")
+ continue;
+ else
+ alert("Only .png files are allowed for screenshots");
+ return false;
+ }
+ return true;
+}
+</script>
+{% endblock %}
+
+{% block content %}
+<center>
+ <h4>Submitting code for the book </h4>
+ <h4> {{ curr_book.title }} by {{ curr_book.author }}</h4>
+</center>
+<hr>
+<div id="content-wrap" style="max-width:600px;">
+ <p>Upload chapters as individual IPython notebooks. Please do not use spaces to name your Ipython Notebook files. For ex.
+ use "chapter1.ipynb instead of chapter 1.ipynb"</p>
+ <form action="/submit-code-old/{{ curr_book.id }}" method=POST enctype="multipart/form-data">
+ {% csrf_token %}
+ {% for i in no_notebooks %}
+ <input type=text id=chapter{{i}} name=chapter{{i}} placeholder="Chapter {{ forloop.counter }} name">
+ <input type=file id=notebook{{i}} name=notebook{{i}}>
+ {% endfor %}
+ <br>
+ <hr>
+ <p>Upload screenshots of Plots/Graphs/Charts(if any) "that you have plotted" and not from the textbook itself from any cahpter. If there are no plots/graphs/charts, then upload a screenshot of any chapter. Give proper caption for the screen shots. Only .png files are acceptable.</p>
+ {% for i in no_images %}
+ <input type=text id=caption{{i}} name=caption{{i}} placeholder="Caption {{ forloop.counter }}">
+ <input type=file id=image{{i}} name=image{{i}}>
+ {% endfor %}
+ <br><br>
+ <center><input class="btn btn-primary" type=submit value=submit onClick="return validate_content();"></center>
+ </form>
+</div>
+{% endblock %}
diff --git a/tbc/urls.py b/tbc/urls.py
index 7242fd6..b20b4e4 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -22,7 +22,9 @@ urlpatterns = patterns('',
url(r'^submit-sample/(?P<proposal_id>\d+)$', 'tbc.views.SubmitSample', name='SubmitSample'),
url(r'^submit-sample/(?P<proposal_id>\d+)/(?P<old_notebook_id>\d+)$', 'tbc.views.SubmitSample', name='SubmitSample'),
url(r'^confirm-book-details/$', 'tbc.views.ConfirmBookDetails', name='ConfirmBookDetails'),
+ url(r'^submit-book-old/$', 'tbc.views.SubmitBook', name='SubmitBook'),
url(r'^submit-code/$', 'tbc.views.SubmitCode', name='SubmitCode'),
+ url(r'^submit-code-old/(?P<book_id>\d+)$', 'tbc.views.SubmitCodeOld', name='SubmitCodeOld'),
url(r'^update-content/(?P<book_id>\d+)$', 'tbc.views.UpdateContent', name='UpdateContent'),
url(r'^get-zip/(?P<book_id>\d+)$', 'tbc.views.GetZip', name='GetZip'),
url(r'^browse-books/$', 'tbc.views.BrowseBooks', name='BrowseBooks'),
diff --git a/tbc/views.py b/tbc/views.py
index 0f23439..049f838 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -316,9 +316,7 @@ def SubmitBook(request):
context['user'] = curr_user
curr_book = Book.objects.order_by("-id")[0]
curr_book_id = curr_book.id
- proposal_id = Proposal.objects.get(accepted=curr_book)
- add_log(curr_user, curr_book, CHANGE, 'Book submitted', proposal_id)
- return HttpResponseRedirect('/upload-content/'+str(curr_book_id))
+ return HttpResponseRedirect('/submit-code-old/'+str(curr_book_id))
else:
context.update(csrf(request))
context['form'] = form
@@ -332,6 +330,46 @@ def SubmitBook(request):
return render_to_response('tbc/submit-book.html', context)
+def SubmitCodeOld(request, book_id=None):
+ user = request.user
+ curr_profile = Profile.objects.get(user=user)
+ context = {}
+ curr_book = Book.objects.get(id=book_id)
+ if request.method == 'POST':
+ for i in range(1, curr_book.no_chapters+1):
+ chapter = Chapters()
+ chapter.name = request.POST['chapter'+str(i)]
+ chapter.notebook = request.FILES['notebook'+str(i)]
+ chapter.book = curr_book
+ chapter.save()
+ 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()
+ subject = "Python-TBC: Book Submission"
+ message = "Hi "+curr_book.reviewer.name+",\n"+\
+ "A book has been submitted on the Python TBC interface.\n"+\
+ "Details of the Book & Contributor:\n"+\
+ "Contributor: "+curr_book.contributor.user.first_name+" "+curr_book.contributor.user.last_name+"\n"+\
+ "Book Title: "+curr_book.title+"\n"+\
+ "Author: "+curr_book.author+"\n"+\
+ "Publisher: "+curr_book.publisher_place+"\n"+\
+ "ISBN: "+curr_book.isbn+"\n"+\
+ "Follow the link to review the book: \n"+\
+ "http://tbc-python.fossee.in/book-review/"+str(curr_book.id)
+ email_send(curr_book.reviewer.email, subject, message)
+ return HttpResponseRedirect('/?up=done')
+ else:
+ context.update(csrf(request))
+ context['user'] = user
+ context['curr_book'] = curr_book
+ context['no_notebooks'] = [i for i in range(1, curr_book.no_chapters+1)]
+ context['no_images'] = [i for i in range(1, 4)]
+ return render_to_response('tbc/upload-content-old.html', context)
+
+
def SubmitProposal(request):
curr_user = request.user
user_profile = Profile.objects.get(user=curr_user.id)
@@ -852,13 +890,17 @@ def BookReview(request, book_id=None):
book = Book.objects.get(id=book_id)
chapters = Chapters.objects.filter(book=book).order_by('name')
images = ScreenShots.objects.filter(book=book)
- proposal = Proposal.objects.get(accepted=book)
- logs = ActivityLog.objects.filter(proposal_id=proposal.id)
- context['logs'] = logs
+ #for old books (before automated proposal)
+ try:
+ proposal = Proposal.objects.get(accepted=book)
+ logs = ActivityLog.objects.filter(proposal_id=proposal.id)
+ context['logs'] = logs
+ context['proposal'] = proposal
+ except:
+ pass
context['chapters'] = chapters
context['images'] = images
context['book'] = book
- context['proposal'] = proposal
context['reviewer'] = request.user
context.update(csrf(request))
return render_to_response('tbc/book-review-details.html', context)