From f71c45f91d582375643de198880b87e994300596 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 30 Jul 2014 11:33:35 +0530 Subject: added changes to reject proposal --- tbc/templates/tbc/reject-proposal.html | 17 +++++++++++++ tbc/templates/tbc/review-proposal.html | 22 +++++++++-------- tbc/urls.py | 1 + tbc/views.py | 44 +++++++++++++++++++++++++++++----- 4 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 tbc/templates/tbc/reject-proposal.html 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 %} +

Proposal Rejection

+
+

Rejecting proposal submitted by {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}.

+
+{% csrf_token %} + + + + + + +
To
Reason/Remarks for rejection
+
+{% 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 %} -

New Proposals

+

New Proposals

+
+ {% if no_new_proposal %} +

There are no new proposals

+ {% endif %}
    {% for proposal in proposals %} -
  1. Propsal from {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}
  2. +
  3. Propsal from {{ proposal.user.user.first_name }} {{ proposal.user.user.last_name }}

  4. {% for textbook in proposal.textbooks.all %}

-

Old Proposals

+

Proposals in Sample Notebook phase

+
    {% for proposal in old_proposals %} -
  1. Propsal from {{ proposal.proposal.user.user.first_name }} {{ proposal.proposal.user.user.last_name }}
  2. +

  3. Propsal from {{ proposal.proposal.user.user.first_name }} {{ proposal.proposal.user.user.last_name }}
  4. {% for textbook in proposal.proposal.textbooks.all %}
    @@ -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 %}
    Book Accepted/Alloted: {{ proposal.proposal.accepted.title }}
    {% ifequal proposal.proposal.status "samples" %} @@ -73,7 +75,7 @@
    Contributor has not submitted sample notebook yet.
    {% endif %} Disapprove Samples - Alot Book + Alot Book {% endifequal %}
    {% 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\d+)/(?P\d+)$', 'tbc.views.ReviewProposals', name='ReviewProposals'), url(r'^disapprove-sample-notebook/(?P\d+)$', 'tbc.views.DisapproveProposal', name='DisapproveProposal'), + url(r'^allot-book/(?P\d+)$', 'tbc.views.AllotBook', name='AllotBook'), url(r'^reject-proposal/(?P\d+)$', 'tbc.views.RejectProposal', name='RejectProposal'), url(r'^book-review/(?P\d+)$', 'tbc.views.BookReview', name='BookReview'), url(r'^approve-book/(?P\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): -- cgit