diff options
author | hardythe1 | 2015-01-28 16:28:43 +0530 |
---|---|---|
committer | hardythe1 | 2015-01-28 16:28:43 +0530 |
commit | 7e35731a8c0e90be2a9a67d8a5ab82125653b2f2 (patch) | |
tree | 24d1bf2ecd745341a129430d838e7fd93ad6e091 | |
parent | 41d1b355635ab7030c3c2f1e4b02822b41763581 (diff) | |
download | Python-TBC-Interface-7e35731a8c0e90be2a9a67d8a5ab82125653b2f2.tar.gz Python-TBC-Interface-7e35731a8c0e90be2a9a67d8a5ab82125653b2f2.tar.bz2 Python-TBC-Interface-7e35731a8c0e90be2a9a67d8a5ab82125653b2f2.zip |
fixed error in notify changes and edited message for sample disapproval
-rwxr-xr-x | tbc/views.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tbc/views.py b/tbc/views.py index 6a76b3d..7ebc44c 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -637,10 +637,9 @@ def DisapproveProposal(request, proposal_id=None): 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 + message = """Hi, """+proposal.user.user.first_name+""",\n"""+\ +"""Sample notebook for the book titled, """+proposal.accepted.title+"""requires +following changes: \n"""+changes_required add_log(request.user, proposal, CHANGE, 'Sample disapproved', proposal_id, chat=subject + '\n' + changes_required) context.update(csrf(request)) @@ -1078,17 +1077,27 @@ def NotifyChanges(request, book_id=None): context = {} if is_reviewer(request.user): book = Book.objects.get(id=book_id) - proposal = Proposal.objects.get(accepted=book) if request.method == 'POST': - proposal.status = "codes disapproved" - proposal.save() + try: + proposal = Proposal.objects.get(accepted=book) + proposal.status = 'codes disapproved' + proposal.save() + msg = "Notified Changes" + except Proposal.DoesNotExist: + proposal = Proposal() + proposal.user = book.contributor + proposal.accepted = book + proposal.status = 'codes disapproved' + proposal.save() + msg = "Notified changes for old book" changes_required = request.POST['changes_required'] subject = "Python-TBC: Corrections Required" message = "Hi, "+book.contributor.user.first_name+",\n"+\ "Book titled, "+book.title+" requires following changes: \n"+\ changes_required + return HttpResponse(message) context.update(csrf(request)) - add_log(request.user, book, CHANGE, 'Changes notification', + add_log(request.user, book, CHANGE, msg, proposal.id, chat=subject+'\n'+changes_required) email_send(book.contributor.user.email, subject, message) return HttpResponseRedirect("/book-review/?mail_notify=done") |