summaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
authorJayaram Pai2014-06-19 12:06:18 +0530
committerJayaram Pai2014-06-19 12:06:18 +0530
commitd6c971711f5b95119ee4a868559ba0256e95c937 (patch)
treea000cacadeb17168a3df85916074ef62561d87d8 /website
parent21051301328e664963532be8384d4b0fb1addc84 (diff)
downloadFOSSEE-Forum-d6c971711f5b95119ee4a868559ba0256e95c937.tar.gz
FOSSEE-Forum-d6c971711f5b95119ee4a868559ba0256e95c937.tar.bz2
FOSSEE-Forum-d6c971711f5b95119ee4a868559ba0256e95c937.zip
added unanswered question notification - beta
Diffstat (limited to 'website')
-rw-r--r--website/urls.py1
-rw-r--r--website/views.py30
2 files changed, 30 insertions, 1 deletions
diff --git a/website/urls.py b/website/urls.py
index 5d7a654..d05a5f0 100644
--- a/website/urls.py
+++ b/website/urls.py
@@ -17,6 +17,7 @@ urlpatterns = patterns('',
url(r'^user/(?P<user_id>\d+)/answers/$', 'website.views.user_answers', name='user_answers'),
url(r'^clear-notifications/$', 'website.views.clear_notifications', name='clear_notifications'),
url(r'^search/$', 'website.views.search', name='search'),
+ url(r'^unanswered-notification/$', 'website.views.unanswered_notification', name='unanswered_notification'),
# Ajax helpers
url(r'^ajax-tutorials/$', 'website.views.ajax_tutorials', name='ajax_tutorials'),
diff --git a/website/views.py b/website/views.py
index 01f07ed..5a6dd58 100644
--- a/website/views.py
+++ b/website/views.py
@@ -513,9 +513,37 @@ def forums_mail(to = '', subject='', message=''):
# Start of email send
email = EmailMultiAlternatives(
subject,'', 'forums',
- [to],
+ to.split(','),
headers={"Content-type":"text/html;charset=iso-8859-1"}
)
email.attach_alternative(message, "text/html")
email.send(fail_silently=True)
# End of email send
+
+# daily notifications for unanswered questions.
+def unanswered_notification(request):
+ questions = Question.objects.all()
+ total_count = 0
+ message = """
+ The following questions are left unanswered.
+ Please take a look at them. <br><br>
+ """
+ for question in questions:
+ if not question.answer_set.count():
+ total_count += 1
+ message += """
+ #{0}<br>
+ Title: <b>{1}</b><br>
+ Category: <b>{2}</b><br>
+ Link: <b>{3}</b><br>
+ <hr>
+ """.format(
+ total_count,
+ question.title,
+ question.category,
+ 'http://forums.spoken-tutorial.org/question/' + str(question.id)
+ )
+ to = "rush2jrp@gmail.com, jayaram@iitb.ac.in"
+ subject = "Unanswered questions in the forums."
+ forums_mail(to, subject, message)
+ return HttpResponse(message)