summaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
authorJayaram Pai2013-12-23 18:35:55 +0530
committerJayaram Pai2013-12-23 18:35:55 +0530
commit5f70865c790fa61d395b2f083cb1bb459247a7dd (patch)
tree114c6c8bbb946b09fb6f261c2c47fec48890e4f1 /website
parent7bd1b1a977e3d1760c94fe2d07a6db66be22098b (diff)
downloadFOSSEE-Forum-5f70865c790fa61d395b2f083cb1bb459247a7dd.tar.gz
FOSSEE-Forum-5f70865c790fa61d395b2f083cb1bb459247a7dd.tar.bz2
FOSSEE-Forum-5f70865c790fa61d395b2f083cb1bb459247a7dd.zip
added email.send() when a new question is asked
Diffstat (limited to 'website')
-rw-r--r--website/views.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/website/views.py b/website/views.py
index 0e74616..e470e09 100644
--- a/website/views.py
+++ b/website/views.py
@@ -124,6 +124,30 @@ def new_question(request):
question.body = cleaned_data['body']
question.views= 1
question.save()
+
+ # Sending email when a new question is asked
+ subject = 'New Forum Question'
+ message = """
+ A new question has been posted in the Spoken-Tutorial Forum. <br>
+ Category: <b>{0}</b><br>
+ Tutorial: <b>{1}</b><br>
+ Link: <a href="{2}">{2}</a><br>
+ """.format(
+ question.category,
+ question.tutorial,
+ 'http://forums.spoken-tutorial.org/question/'+str(question.id)
+ )
+
+ email = EmailMultiAlternatives(
+ subject,'', 'forums',
+ ['team@spoken-tutorial.org', 'team@fossee.in'],
+ headers={"Content-type":"text/html;charset=iso-8859-1"}
+ )
+
+ email.attach_alternative(message, "text/html")
+ email.send(fail_silently=True)
+ # End of email send
+
return HttpResponseRedirect('/')
else:
form = NewQuestionForm()
@@ -331,20 +355,3 @@ def ajax_time_search(request):
}
return render(request, 'website/templates/ajax-time-search.html', context)
-
-def test(request):
- subject = 'New Forum Question'
- message = """
- A new question has been posted in the Spoken-Tutorial Forum. <br>
- Category: {0}<br>
- Tutorial: {1}<br>
- <a href="{2}">{2}</a> <br>
- """.format('Test Cat', 'Test Tut', 'http://spoken-tutorial.org')
- email = EmailMultiAlternatives(
- subject,'', 'forums',
- ['rush2jrp@gmail.com', 'vishnukraj007@gmail.com'],
- headers={"Content-type":"text/html;charset=iso-8859-1"}
- )
- email.attach_alternative(message, "text/html")
- email.send(fail_silently=True)
- return HttpResponse("done")