summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
Diffstat (limited to 'tbc')
-rw-r--r--tbc/models.py2
-rw-r--r--tbc/templates/tbc/disapprove-sample.html17
-rw-r--r--tbc/templates/tbc/review-proposal.html24
-rw-r--r--tbc/templates/tbc/submit-sample.html2
-rw-r--r--tbc/urls.py2
-rwxr-xr-xtbc/views.py46
6 files changed, 72 insertions, 21 deletions
diff --git a/tbc/models.py b/tbc/models.py
index 00cb56b..a1f2408 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -58,7 +58,7 @@ def get_image_dir(instance, filename):
def get_sample_dir(instance, filename):
- user_name = instance.user.user.first_name+instance.user.user.last_name
+ user_name = instance.proposal.user.user.first_name+instance.proposal.user.user.last_name
return 'sample_notebooks/%s/%s' % (user_name, filename.replace(' ', '_'))
class Profile(models.Model):
diff --git a/tbc/templates/tbc/disapprove-sample.html b/tbc/templates/tbc/disapprove-sample.html
new file mode 100644
index 0000000..2632edb
--- /dev/null
+++ b/tbc/templates/tbc/disapprove-sample.html
@@ -0,0 +1,17 @@
+{% extends 'base.html' %}
+{% load static %}
+{% block content %}
+<center><h3>Diapprove Sample Notebook</h3>
+<hr>
+<h4>Notifing Chages for book {{ proposal.accepted.title }} to {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}</h4></center>
+<form action="/disapprove-sample-notebook/{{ proposal.id }}" method=POST enctype="multipart/form-data">
+{% csrf_token %}
+ <table>
+ <tr><td>To</td></tr>
+ <tr><td><input type="text" value="{{ proposal.user.user.email }}" readonly></td></tr>
+ <tr><td>Changes Required</td></tr>
+ <tr><td><textarea rows="15" cols="100" name="changes_required" style="width:100%;"></textarea></td></tr>
+ <tr><td><input class="btn btn-primary" type="submit" value="Send"></td></tr>
+ </table>
+</form>
+{% endblock %}
diff --git a/tbc/templates/tbc/review-proposal.html b/tbc/templates/tbc/review-proposal.html
index 3c8366b..c451db6 100644
--- a/tbc/templates/tbc/review-proposal.html
+++ b/tbc/templates/tbc/review-proposal.html
@@ -35,9 +35,9 @@
<center><h3>Old Proposals</h3></center>
<ol>
{% for proposal in old_proposals %}
- <li><h5>Propsal from {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}</h5></li>
+ <li><h5>Propsal from {{ proposal.proposal.user.user.first_name }} {{ proposal.proposal.user.user.last_name }}</h5></li>
<div class="accordion" id="accordion2">
- {% for textbook in proposal.textbooks.all %}
+ {% for textbook in proposal.proposal.textbooks.all %}
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse{{forloop.counter}}">
@@ -58,18 +58,22 @@
{% endfor %}
<h5>
<b>Status:</b>
- {% ifequal proposal.status "samples" %}
- Contributor is required to submit sample notebook
+ {% ifequal proposal.proposal.status "samples" %}
+ Sample notebook phase
{% endifequal %}
- {% ifequal proposal.status "book alloted" %}
+ {% ifequal proposal.proposal.status "book alloted" %}
Book has been alloted. Contributor is required to submmit the codes for entire book.
{% endifequal %}
</h5>
- <h5><b>Book Accepted/Alloted:</b> {{ proposal.accepted.title }}</h5>
- {% ifequal proposal.status "samples" %}
- <h5><a href="{% static 'uploads/' %}{{ chapter.notebook }}">sample notebook</a><br></h5>
- <a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.id %}">Disapprove Samples</a>
- <a class="btn btn-primary" href="{% url 'tbc:RejectProposal' proposal.id %}">Alot Book</a>
+ <h5><b>Book Accepted/Alloted:</b> {{ proposal.proposal.accepted.title }}</h5>
+ {% ifequal proposal.proposal.status "samples" %}
+ {% if proposal.sample.sample_notebook %}
+ <h5><a href="{% static 'uploads/' %}{{ proposal.sample.sample_notebook }}">sample notebook</a><br></h5>
+ {% else %}
+ <h5>Contributor has not submitted sample notebook yet.</h5>
+ {% endif %}
+ <a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.proposal.id %}">Disapprove Samples</a>
+ <a class="btn btn-primary" href="{% url 'tbc:RejectProposal' proposal.proposal.id %}">Alot Book</a>
{% endifequal %}
</div>
{% endfor %}
diff --git a/tbc/templates/tbc/submit-sample.html b/tbc/templates/tbc/submit-sample.html
index fde3079..b26e8ae 100644
--- a/tbc/templates/tbc/submit-sample.html
+++ b/tbc/templates/tbc/submit-sample.html
@@ -24,7 +24,7 @@ function validate_content()
{% block content %}
<div id="content-wrap" style="max-width:600px;">
- <p>You are uploading sample notebook for the book {{ proposal.accepted.title }} by {{ proposal.accepted.author }}</p>
+ <h5>You are uploading sample notebook for the book {{ proposal.accepted }} by {{ proposal.accepted.author }}</h5>
<p>Only .ipynb files are acceptable</p>
<form action="/submit-sample/{{ proposal.id }}" method=POST enctype="multipart/form-data" onSubmit="return validate_content();">
{% csrf_token %}
diff --git a/tbc/urls.py b/tbc/urls.py
index 8bbd025..06f3636 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -30,7 +30,7 @@ urlpatterns = patterns('',
url(r'^book-review/$', 'tbc.views.BookReview', name='BookReview'),
url(r'^proposal-review/$', 'tbc.views.ReviewProposals', name='ReviewProposals'),
url(r'^proposal-review/(?P<proposal_id>\d+)/(?P<textbook_id>\d+)$', 'tbc.views.ReviewProposals', name='ReviewProposals'),
- url(r'^disapprove-proposal/(?P<proposal_id>\d+)$', 'tbc.views.DisapproveProposal', name='DisapproveProposal'),
+ url(r'^disapprove-sample-notebook/(?P<proposal_id>\d+)$', 'tbc.views.DisapproveProposal', name='DisapproveProposal'),
url(r'^reject-proposal/(?P<proposal_id>\d+)$', 'tbc.views.RejectProposal', name='RejectProposal'),
url(r'^book-review/(?P<book_id>\d+)$', 'tbc.views.BookReview', name='BookReview'),
url(r'^approve-book/(?P<book_id>\d+)$', 'tbc.views.ApproveBook', name='ApproveBook'),
diff --git a/tbc/views.py b/tbc/views.py
index 3f891b1..b60b766 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -366,18 +366,38 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None):
else:
new_proposals = Proposal.objects.filter(status="pending")
other_status = ['samples', 'book alloted']
- old_proposals = Proposal.objects.filter(status__in=other_status)
+ old_proposals = []
+ sample_notebook = ''
+ proposals = Proposal.objects.filter(status__in=other_status)
+ for proposal in proposals:
+ try:
+ sample_notebook = SampleNotebook.objects.get(proposal=proposal)
+ except:
+ sample_notebook = None
+ obj = {'proposal':proposal, 'sample':sample_notebook}
+ old_proposals.append(obj)
context['proposals'] = new_proposals
context['old_proposals'] = old_proposals
return render_to_response('tbc/review-proposal.html', context)
def DisapproveProposal(request, proposal_id=None):
- if request.method == "POST":
- return HttpResponse("Dispproved")
+ context = {}
+ context.update(csrf(request))
+ proposal = Proposal.objects.get(id=proposal_id)
+ if request.method == 'POST':
+ changes_required = request.POST['changes_required']
+ subject = "Python-TBC: Corrections Required in the sample notebook"
+ message = "Hi, "+proposal.user.user.first_name+",\n"+\
+ "Sample notebook for the book titled, "+proposal.accepted.title+"\
+ requires following changes: \n"+\
+ changes_required
+ context.update(csrf(request))
+ return HttpResponseRedirect("/book-review/?mail_notify=done")
else:
- return HttpResponse("no post")
-
+ context['proposal'] = proposal
+ return render_to_response('tbc/disapprove-sample.html', context)
+
def RejectProposal(request, proposal_id=None):
if request.method == "POST":
return HttpResponse("Rejected")
@@ -386,11 +406,21 @@ def RejectProposal(request, proposal_id=None):
def SubmitSample(request, proposal_id=None):
+ context = {}
+ context.update(csrf(request))
if request.method == "POST":
- return HttpResponse("POST")
+ curr_proposal = Proposal.objects.get(id=proposal_id)
+ sample_notebook = SampleNotebook()
+ sample_notebook.proposal = curr_proposal
+ sample_notebook.name = request.POST.get('ch_name')
+ sample_notebook.sample_notebook = request.FILES['sample_notebook']
+ sample_notebook.save()
+ return HttpResponse("done")
else:
- books = Book.objects.filter(approved=True)
- return HttpResponse(books)
+ profile = Profile.objects.get(user=request.user)
+ proposal = Proposal.objects.get(user=profile, status='samples')
+ context['proposal'] = proposal
+ return render_to_response('tbc/submit-sample.html', context)
def UpdateBook(request):