summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtbc/views.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/tbc/views.py b/tbc/views.py
index 2bfbab5..d93a410 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -37,7 +37,7 @@ def add_log(user, object, flag, message, proposal_id=None, chat='No message'):
def email_send(to,subject,msg):
try:
smtpObj = smtplib.SMTP('localhost')
- mail_from = "textbook@fosse.in"
+ mail_from = "textbook@fossee.in"
message = MIMEText(msg)
message['Subject'] = subject
message['From'] = mail_from
@@ -341,7 +341,7 @@ def SubmitBook(request):
data = form.save(commit=False)
profile = Profile.objects.get(user=request.user.id)
data.contributor = profile
- data.reviewer = Reviewer.objects.get(pk=1)
+ data.reviewer = Reviewer.objects.get(pk=2)
data.save()
context['user'] = curr_user
curr_book = Book.objects.order_by("-id")[0]
@@ -594,7 +594,7 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None):
new_book.year_of_pub = accepted_book.year_of_pub
new_book.no_chapters = accepted_book.no_chapters
new_book.contributor = proposal.user
- new_book.reviewer = Reviewer.objects.get(pk=1)
+ new_book.reviewer = Reviewer.objects.get(pk=2)
new_book.save()
proposal.status = "samples"
proposal.accepted = new_book
@@ -640,10 +640,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+""",\n
+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))
@@ -1081,17 +1080,26 @@ 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
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")