summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
authorhardythe12014-07-30 11:33:35 +0530
committerhardythe12014-07-30 11:33:35 +0530
commitf71c45f91d582375643de198880b87e994300596 (patch)
treecb570604ec58637fd1053aa85445b8252528dd3d /tbc
parentc435fddecde1fc7d13687d23740062151bc52a72 (diff)
downloadPython-TBC-Interface-f71c45f91d582375643de198880b87e994300596.tar.gz
Python-TBC-Interface-f71c45f91d582375643de198880b87e994300596.tar.bz2
Python-TBC-Interface-f71c45f91d582375643de198880b87e994300596.zip
added changes to reject proposal
Diffstat (limited to 'tbc')
-rw-r--r--tbc/templates/tbc/reject-proposal.html17
-rw-r--r--tbc/templates/tbc/review-proposal.html22
-rw-r--r--tbc/urls.py1
-rwxr-xr-xtbc/views.py44
4 files changed, 68 insertions, 16 deletions
diff --git a/tbc/templates/tbc/reject-proposal.html b/tbc/templates/tbc/reject-proposal.html
new file mode 100644
index 0000000..11ce874
--- /dev/null
+++ b/tbc/templates/tbc/reject-proposal.html
@@ -0,0 +1,17 @@
+{% extends 'base.html' %}
+{% load static %}
+{% block content %}
+<center><h3>Proposal Rejection</h3>
+<hr>
+<h4>Rejecting proposal submitted by {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}.</h4></center>
+<form action="/reject-proposal/{{ 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>Reason/Remarks for rejection</td></tr>
+ <tr><td><textarea rows="15" cols="100" name="remarks" 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 c451db6..98c26a1 100644
--- a/tbc/templates/tbc/review-proposal.html
+++ b/tbc/templates/tbc/review-proposal.html
@@ -1,16 +1,20 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
- <center><h3>New Proposals</h3></center>
+ <center><h2>New Proposals</h2></center>
+ <hr>
+ {% if no_new_proposal %}
+ <center><h4>There are no new proposals</h4></center>
+ {% endif %}
<ol>
{% for proposal in proposals %}
- <li><h5>Propsal from {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}</h5></li>
+ <li><h4>Propsal from {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}</h4></li>
<div class="accordion" id="accordion2">
{% for textbook in 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}}">
- {{ textbook.title }} - Book Preference {{ forloop.counter }}
+ Book Preference {{ forloop.counter }} - {{ textbook.title }}
</a>
</div>
<div id="collapse{{forloop.counter}}" class="accordion-body collapse">
@@ -32,16 +36,17 @@
{% endfor %}
</ol>
<hr>
- <center><h3>Old Proposals</h3></center>
+ <center><h2>Proposals in Sample Notebook phase</h2></center>
+ <hr>
<ol>
{% for proposal in old_proposals %}
- <li><h5>Propsal from {{ proposal.proposal.user.user.first_name }} {{ proposal.proposal.user.user.last_name }}</h5></li>
+ <h4><li>Propsal from {{ proposal.proposal.user.user.first_name }} {{ proposal.proposal.user.user.last_name }}</h4></li>
<div class="accordion" id="accordion2">
{% 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}}">
- {{ textbook.title }} - Book Preference {{ forloop.counter }}
+ Book Preference {{ forloop.counter }} - {{ textbook.title }}
</a>
</div>
<div id="collapse{{forloop.counter}}" class="accordion-body collapse">
@@ -61,9 +66,6 @@
{% ifequal proposal.proposal.status "samples" %}
Sample notebook phase
{% endifequal %}
- {% 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.proposal.accepted.title }}</h5>
{% ifequal proposal.proposal.status "samples" %}
@@ -73,7 +75,7 @@
<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>
+ <a class="btn btn-primary" href="{% url 'tbc:AllotBook' proposal.proposal.id %}">Alot Book</a>
{% endifequal %}
</div>
{% endfor %}
diff --git a/tbc/urls.py b/tbc/urls.py
index 06f3636..57a2ddd 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -31,6 +31,7 @@ urlpatterns = patterns('',
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-sample-notebook/(?P<proposal_id>\d+)$', 'tbc.views.DisapproveProposal', name='DisapproveProposal'),
+ url(r'^allot-book/(?P<proposal_id>\d+)$', 'tbc.views.AllotBook', name='AllotBook'),
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 b60b766..c2356c7 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -300,6 +300,7 @@ def SubmitProposal(request):
context['user'] = curr_user
user_proposals = Proposal.objects.filter(user=user_profile)
can_submit_new = True
+ matching_books = []
for proposal in user_proposals:
if proposal.status is not "book completed":
can_submit_new = False
@@ -313,6 +314,12 @@ def SubmitProposal(request):
book_editions = request.POST.getlist('edition')
book_years = request.POST.getlist('year_of_pub')
book_chapters = request.POST.getlist('no_chapters')
+ """for title in book_titles:
+ temp_books = Book.objects.filter(title__icontains=title)
+ for book in temp_books:
+ matching_books.append(book)
+ matching_books = set(matching_books)
+ return HttpResponse(matching_books)"""
for item in range(3):
tempbook = TempBook()
tempbook.title = book_titles[item]
@@ -365,10 +372,8 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None):
return HttpResponse("Approved")
else:
new_proposals = Proposal.objects.filter(status="pending")
- other_status = ['samples', 'book alloted']
old_proposals = []
- sample_notebook = ''
- proposals = Proposal.objects.filter(status__in=other_status)
+ proposals = Proposal.objects.filter(status='samples')
for proposal in proposals:
try:
sample_notebook = SampleNotebook.objects.get(proposal=proposal)
@@ -376,6 +381,11 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None):
sample_notebook = None
obj = {'proposal':proposal, 'sample':sample_notebook}
old_proposals.append(obj)
+ if new_proposals.count() > 0:
+ no_new_proposal = False
+ else:
+ no_new_proposal = True
+ context['no_new_proposal'] = no_new_proposal
context['proposals'] = new_proposals
context['old_proposals'] = old_proposals
return render_to_response('tbc/review-proposal.html', context)
@@ -392,17 +402,39 @@ def DisapproveProposal(request, proposal_id=None):
"Sample notebook for the book titled, "+proposal.accepted.title+"\
requires following changes: \n"+\
changes_required
+ email_send(proposal.user.user.email, subject, message)
context.update(csrf(request))
return HttpResponseRedirect("/book-review/?mail_notify=done")
else:
context['proposal'] = proposal
return render_to_response('tbc/disapprove-sample.html', context)
+
+
+def AllotBook(requrest, proposal_id=None):
+ context = {}
+ proposal = Proposal.objects.get(id=proposal_id)
+ proposal.status = "book alloted"
+ proposal.save()
+ return HttpResponseRedirect("/book-review/?book_alloted=done")
+
def RejectProposal(request, proposal_id=None):
- if request.method == "POST":
- return HttpResponse("Rejected")
+ context = {}
+ context.update(csrf(request))
+ proposal = Proposal.objects.get(id=proposal_id)
+ if request.method == 'POST':
+ proposal.status = 'rejected'
+ proposal.save()
+ remarks = request.POST['remarks']
+ subject = "Python-TBC: Rejection of Proposal"
+ message = "Dear "+proposal.user.user.first_name+"\nYour proposal has been\
+ rejected. "+request.POST.get('remarks')
+ email_send(proposal.user.user.email, subject, message)
+ context.update(csrf(request))
+ return HttpResponseRedirect("/book-review/?reject-proposal=done")
else:
- return HttpResponse("no post")
+ context['proposal'] = proposal
+ return render_to_response('tbc/reject-proposal.html', context)
def SubmitSample(request, proposal_id=None):