summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tbc/models.py1
-rw-r--r--tbc/templates/tbc/book-review-details.html3
-rw-r--r--tbc/templates/tbc/confirm-details.html48
-rw-r--r--tbc/templates/tbc/review-proposal.html12
-rw-r--r--tbc/templates/tbc/update-code.html22
-rwxr-xr-xtbc/views.py57
6 files changed, 135 insertions, 8 deletions
diff --git a/tbc/models.py b/tbc/models.py
index eb61c7c..67a6d09 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -41,6 +41,7 @@ ABOUT_PROJ = (("pythontbc website", "Python TBC Website"),
PROPOSAL_STATUS = (("pending","Pending"),
("samples","Samples"),
+ ("sample submitted", "Sample Submitted"),
("sample disapproved", "Sample Disapproved"),
("sample resubmitted", "Sample Resubmitted"),
("book alloted","Book Alloted"),
diff --git a/tbc/templates/tbc/book-review-details.html b/tbc/templates/tbc/book-review-details.html
index 7e52c26..1aa888c 100644
--- a/tbc/templates/tbc/book-review-details.html
+++ b/tbc/templates/tbc/book-review-details.html
@@ -31,6 +31,9 @@
</select>
<input type=submit value=GO>
</form>
+ {% ifequal proposal.status 'codes disapproved' %}
+ <p>The required corrections have already been notified to the user. Kindly check the Activity Log for more details</p>
+ {% endifequal %}
{% endif %}
<table>
<tr><td>Author: &nbsp;&nbsp;<td>{{ book.author }}
diff --git a/tbc/templates/tbc/confirm-details.html b/tbc/templates/tbc/confirm-details.html
index 26007ea..96393ac 100644
--- a/tbc/templates/tbc/confirm-details.html
+++ b/tbc/templates/tbc/confirm-details.html
@@ -1,11 +1,57 @@
{% extends 'base.html' %}
{% block content %}
<div id="content-wrap" style="max-width:600px;">
+ <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="myModalLabel">Verify Details</h3>
+ </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>
+ <p>Note: Consider only those chapters which have solved examples</p></p>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary" data-dismiss="modal">Ok</button>
+ </div>
+ </div>
+ <div id="chapterModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="myModalLabel">Invalid number of chapters</h3>
+ </div>
+ <div class="modal-body">
+ <p>No of chapters cannot be less than 0 or greater than 100</p>
+ <p>However, if the textbook has more than 100 chapters kindly contact the reviewer.</p>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary" data-dismiss="modal">Ok</button>
+ </div>
+ </div>
<form action="/confirm-book-details/" method=POST enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_table }}
<br>
- <input class="btn btn-primary" type=submit value="Update Book">
+ <input class="btn btn-primary" type=submit onclick="return validateChapters();" value="Update Details">
</form>
</div>
{% endblock %}
+
+{% block script %}
+ <script>
+ $(document).ready(function() {
+ $("#myModal").modal();
+ });
+
+ function validateChapters()
+ {
+ no_chapters = document.getElementById("id_no_chapters").value
+ if (no_chapters <= 0 || no_chapters > 100)
+ {
+ $("#chapterModal").modal();
+ return false;
+ }
+ return true;
+ }
+ </script>
+{% endblock %}
diff --git a/tbc/templates/tbc/review-proposal.html b/tbc/templates/tbc/review-proposal.html
index 9c6aca9..b660db8 100644
--- a/tbc/templates/tbc/review-proposal.html
+++ b/tbc/templates/tbc/review-proposal.html
@@ -68,7 +68,17 @@
{% endifequal %}
</h5>
<h5><b>Book Accepted/Alloted:</b> {{ proposal.proposal.accepted.title }}</h5>
- {% ifequal proposal.proposal.status "samples" %}
+ {% ifequal proposal.proposal.status "sample resubmitted" %}
+ {% if proposal.sample.sample_notebook %}
+ <h5><a href="{% static 'uploads/' %}{{ proposal.sample.sample_notebook }}">sample notebook</a><br></h5>
+ <a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.proposal.id %}">Disapprove Samples</a>
+ <a class="btn btn-primary" href="{% url 'tbc:AllotBook' proposal.proposal.id %}">Alot Book</a>
+ <h5>This is resubmission of the sample notebook</h5>
+ {% else %}
+ <h5>Contributor has not re submitted sample notebook yet.</h5>
+ {% endif %}
+ {% endifequal %}
+ {% ifequal proposal.proposal.status "sample submitted" %}
{% if proposal.sample.sample_notebook %}
<h5><a href="{% static 'uploads/' %}{{ proposal.sample.sample_notebook }}">sample notebook</a><br></h5>
<a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.proposal.id %}">Disapprove Samples</a>
diff --git a/tbc/templates/tbc/update-code.html b/tbc/templates/tbc/update-code.html
new file mode 100644
index 0000000..cce2038
--- /dev/null
+++ b/tbc/templates/tbc/update-code.html
@@ -0,0 +1,22 @@
+{% extends 'base.html' %}
+{% block content %}
+ <div id="content-wrap" style="max-width:600px;">
+ <p>You are updating codes for the book {{ book.title }} by {{ book.author }}</p>
+ <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 type=text name=chapter{{forloop.counter}} value="{{ chapter.name }}">
+ <input type=file name=notebook{{forloop.counter}}>
+ {% endfor %}
+ <br>
+ <hr>
+ <p>Upload 3 screenshots from any 3 random chapters and give proper captions</p>
+ {% for screenshot in screenshots %}
+ <input type=text name=caption{{forloop.counter}} value="{{ screenshot.caption }}">
+ <input type=file name=image{{forloop.counter}}>
+ {% endfor %}
+ <center><input type=submit value=submit></center>
+ </form>
+ </div>
+{% endblock %}
diff --git a/tbc/views.py b/tbc/views.py
index 4fcb0e2..ce20564 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -503,11 +503,12 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None):
proposal.accepted = new_book
proposal.save()
add_log(user, proposal, CHANGE, 'Proposal accepted', proposal.id)
- return HttpResponse("Approved")
+ return HttpResponseRedirect("/proposal-review")
else:
new_proposals = Proposal.objects.filter(status="pending")
old_proposals = []
- proposals = Proposal.objects.filter(status__in=['samples', 'sample disapproved'])
+ old_proposal_status = ['samples', 'sample disapproved', 'sample resubmitted', 'sample submitted']
+ proposals = Proposal.objects.filter(status__in=old_proposal_status)
for proposal in proposals:
try:
sample_notebook = SampleNotebook.objects.get(proposal=proposal)
@@ -555,7 +556,11 @@ def AllotBook(request, proposal_id=None):
proposal = Proposal.objects.get(id=proposal_id)
proposal.status = "book alloted"
proposal.save()
+ subject = "Python-TBC: Book Alloted"
+ message = "Hi "+proposal.user.user.first_name+",\n"+\
+ "The book has been alloted to you."
add_log(request.user, proposal, CHANGE, 'Book alloted', proposal_id)
+ email_send(proposal.user.user.email, subject, message)
return HttpResponseRedirect("/book-review/?book_alloted=done")
@@ -598,7 +603,7 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None):
old_notebook.name = request.POST.get('ch_name_old')
old_notebook.sample_notebook = request.FILES['old_notebook']
old_notebook.save()
- curr_proposal.status = "samples"
+ curr_proposal.status = "sample resubmitted"
curr_proposal.save()
return HttpResponseRedirect('/?sample_notebook=done')
else:
@@ -607,6 +612,8 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None):
sample_notebook.name = request.POST.get('ch_name')
sample_notebook.sample_notebook = request.FILES['sample_notebook']
sample_notebook.save()
+ curr_proposal.status = "sample submitted"
+ curr_proposal.save()
return HttpResponseRedirect('/?sample_notebook=done')
else:
profile = Profile.objects.get(user=user)
@@ -629,8 +636,19 @@ def ConfirmBookDetails(request):
context = {}
current_user = request.user
user_profile = Profile.objects.get(user=current_user)
- proposal = Proposal.objects.get(user=user_profile, status="book alloted")
+ try:
+ proposal = Proposal.objects.get(user=user_profile, status__in=["book alloted", "codes disapproved"])
+ 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
+ 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():
@@ -654,17 +672,40 @@ def ConfirmBookDetails(request):
book_form.initial['reviewer'] = book_to_update.reviewer
context.update(csrf(request))
context['form'] = book_form
+ context['book'] = book_to_update
return render_to_response('tbc/confirm-details.html', context)
def SubmitCode(request):
user = request.user
curr_profile = Profile.objects.get(user=user)
+ context = {}
try:
- curr_proposal = Proposal.objects.get(user=curr_profile, status='book alloted')
+ curr_proposal = Proposal.objects.get(user=curr_profile, status__in=['book alloted', 'codes disapproved'])
curr_book = curr_proposal.accepted
except:
return HttpResponseRedirect('/?no_book_alloted=true')
+ if curr_proposal.status == "codes disapproved":
+ if request.method == 'POST':
+ chapters = Chapters.objects.filter(book=curr_book)
+ screen_shots = ScreenShots.objects.filter(book=curr_book)
+ counter = 1
+ for chapter in chapters:
+ chapter.name = request.POST['chapter'+str(counter)]
+ chapter.notebook = request.FILES['notebook'+str(counter)]
+ chapter.save()
+ counter += 1
+ counter = 1
+ for screenshot in screen_shots:
+ screenshot.caption = request.POST['caption'+str(counter)]
+ screenshot.image = request.FILES['image'+str(counter)]
+ screenshot.save()
+ counter += 1
+ curr_proposal.status = "codes submitted"
+ curr_proposal.save()
+ add_log(user, curr_book, CHANGE, 'Codes & Screenshots Resubmitted',
+ curr_proposal.id)
+ return HttpResponseRedirect('/')
if request.method == 'POST':
for i in range(1, curr_book.no_chapters+1):
chapter = Chapters()
@@ -680,6 +721,8 @@ def SubmitCode(request):
screenshot.save()
book = Book.objects.order_by("-id")[0]
proposal = Proposal.objects.get(accepted=book)
+ proposal.status = "codes submitted"
+ proposal.save()
subject = "Python-TBC: Book Submission"
message = "Hi "+curr_book.reviewer.name+",\n"+\
"A book has been submitted on the Python TBC interface.\n"+\
@@ -698,7 +741,6 @@ def SubmitCode(request):
email_send(book.reviewer.email, subject, message)
return HttpResponseRedirect('/?up=done')
else:
- context = {}
context.update(csrf(request))
context['user'] = user
context['curr_book'] = curr_book
@@ -812,6 +854,7 @@ def BookReview(request, book_id=None):
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)
@@ -895,6 +938,8 @@ def NotifyChanges(request, book_id=None):
book = Book.objects.get(id=book_id)
proposal = Proposal.objects.get(accepted=book)
if request.method == 'POST':
+ proposal.status = "codes disapproved"
+ proposal.save()
changes_required = request.POST['changes_required']
subject = "Python-TBC: Corrections Required"
message = "Hi, "+book.contributor.user.first_name+",\n"+\