diff options
author | hardythe1 | 2013-11-12 02:13:58 +0530 |
---|---|---|
committer | hardythe1 | 2013-11-12 02:13:58 +0530 |
commit | 9e58057ed4e2637d1009c4fe891ad0f126662b85 (patch) | |
tree | 07769c62c3e70bb3c902a0d39d049135bf46d4d1 /tbc | |
parent | 4b70f4abf1fc29cc36ebb2179e4ddb4fa5258a95 (diff) | |
download | Python-TBC-Interface-9e58057ed4e2637d1009c4fe891ad0f126662b85.tar.gz Python-TBC-Interface-9e58057ed4e2637d1009c4fe891ad0f126662b85.tar.bz2 Python-TBC-Interface-9e58057ed4e2637d1009c4fe891ad0f126662b85.zip |
wrote function to send mail
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/templates/tbc/book-details.html | 5 | ||||
-rw-r--r-- | tbc/views.py | 34 |
2 files changed, 32 insertions, 7 deletions
diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index f2912f5..5c141b1 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -1,12 +1,13 @@ {% extends 'base.html' %} {% load static %} + {% block content %} <center><h3>{{ book.title }}</h3></center> <div class="row-fluid"> {% for image in images %} <div class ="module-list"> - <img src="{% static 'uploads/' %}{{ image.image }}"> - <center><p>{{ image.caption }}</p></center> + <img src="{% static 'uploads/' %}{{ image.image }}"> + <center><p>{{ image.caption }}</p></center> </div> {% endfor %} </div> diff --git a/tbc/views.py b/tbc/views.py index 6203e22..ae29aaa 100644 --- a/tbc/views.py +++ b/tbc/views.py @@ -21,7 +21,7 @@ def email_send(to,subject,msg): message['Subject'] = subject message['From'] = MAIL_FROM message['to'] = to - s.sendmail(settings.MAIL_FROM, to, message.as_string()) + s.sendmail(MAIL_FROM, to, message.as_string()) s.quit() @@ -160,6 +160,19 @@ def ContentUpload(request): screenshot.image = request.FILES['image'+str(i)] screenshot.book = curr_book screenshot.save() + book = Book.objects.order_by("-id")[0] + subject = "Python-TBC: Book Submission" + message = "Hi "+curr_book.reviewer.name+",\n"+\ + "A book has been submitted on the interface.\n"+\ + "Details of the Book & Contributor are:\n"+\ + "Contributor: "+curr_book.contributor.user.first_name+curr_book.contributor.user.last_name+"\n"+\ + "Book Title: "+curr_book.title+"\n"+\ + "Author: "+curr_book.author+"\n"+\ + "Publisher: "+curr_book.publisher_place+"\n"+\ + "ISBN: "+curr_book.isbn+"\n"+\ + "Follow the link to review the book: \n"+\ + "http://dev.fossee.in/book-review/"+str(curr_book.id) + email_send(book.reviewer.email, subject, message) return HttpResponseRedirect('/') context = {} context.update(csrf(request)) @@ -198,14 +211,16 @@ def GetZip(request, book_id=None): def BookDetails(request, book_id=None): - user = request.user + context = {} + if request.user.is_anonymous(): + context['user'] = None + else: + context['user'] = request.user book = Book.objects.get(id=book_id) chapters = Chapters.objects.filter(book=book) images = ScreenShots.objects.filter(book=book) - context = {} context['chapters'] = chapters context['images'] = images - context['user'] = user context['book'] = book return render_to_response('tbc/book-details.html', context) @@ -261,9 +276,14 @@ def ApproveBook(request, book_id=None): os.popen("git commit -m "+commit_msg) os.popen("git push")""" context['user'] = user - return HttpResponse("worked") + return HttpResponseRedirect("/book-review") elif request.method == 'POST' and request.POST['approve_notify'] == "notify": context['user'] = user + book = Book.objects.get(id=book_id) + subject = "Python-TBC: Book Submission" + message = "Hi "+Book.reviewer.name+",\n"\ + "A book has been submitted on the interface.\n"\ + "" return HttpResponse("Mail Sent") else: context['user'] = user @@ -271,6 +291,10 @@ def ApproveBook(request, book_id=None): def BrowseBooks(request): context = {} + if request.user.is_anonymous(): + context['user'] = None + else: + context['user'] = request.user images = [] if request.method == 'POST': category = request.POST['category'] |