diff options
Diffstat (limited to 'website')
-rw-r--r-- | website/urls.py | 1 | ||||
-rw-r--r-- | website/views.py | 30 |
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) |