Send mails to all reviewers.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Tue, 11 Aug 2009 04:03:27 +0530
changeset 40 7f6f4b8525b8
parent 39 e7880a8f7e04
child 41 64249ebaf65a
Send mails to all reviewers.
app/projrev/views/proposal.py
--- a/app/projrev/views/proposal.py	Tue Aug 11 03:38:51 2009 +0530
+++ b/app/projrev/views/proposal.py	Tue Aug 11 04:03:27 2009 +0530
@@ -12,6 +12,7 @@
 import os
 import time
 
+from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
 from django.http import HttpResponse
 from django.http import HttpResponseRedirect
@@ -118,21 +119,7 @@
 
       project.micr_code = cleaned_data['micr_code']
 
-      subject = "[Sakshath] MICR Code of the new proposal submitted"
-      message = """Hi,
-   We have received a new proposal for National Mission on education from your, 
-email address "%s", to the http://sakshath.ac.in portal. The MICR Code of the
-submitted proposal is: 
-  MICR Code: %s
-
-Please remember this code for all future references.
-
-
---  
-Regards,
-Saksath admin""" % (request.user.username, project.micr_code)
-
-      request.user.email_user(subject=subject, message=message)
+      send_mails(request, project)
 
     project.status = 'new'
     micr_code = project.micr_code
@@ -456,3 +443,58 @@
   template = 'projrev/proposal/myreviews.html'
 
   return render_to_response(template, RequestContext(request, context))
+
+def send_mails(request, project):
+  """Send mails to the user and all the reviewers after the project is created.
+  """
+  pass
+
+  subject = '[Sakshath] MICR Code of the new proposal submitted'
+
+  message = """Hi,
+   We have received a new proposal for National Mission on education from your, 
+email address "%s", to the http://sakshath.ac.in portal. The MICR Code of the
+submitted proposal is: 
+  MICR Code: %s
+
+Please remember this code for all future references.
+
+
+--  
+Regards,
+Saksath admin""" % (request.user.username, project.micr_code)
+
+  request.user.email_user(subject=subject, message=message)
+
+  subject = '[Sakshath] A new proposal has been submitted for review'
+
+  message_template = """Dear %(user)s,
+
+  A new project proposal has been uploaded on the site for reviewing. The details are as follows:
+
+*Title:* %(title)s
+*Institution:* %(institution)s
+*Address:* %(address)s
+*City:* %(city)s
+*State:* %(state)s
+*Phone Number:* %(ph_no)s
+*Email ID:* %(email)s
+
+To review the proposal please logon to: <a href="">some website</a>
+"""
+
+  reviewers = User.objects.all().filter(is_staff__exact='1')
+
+  for reviewer in reviewers:
+    message = message_template % {
+        'user': reviewer.username,
+        'title': project.title,
+        'institution': project.institution,
+        'address': project.address,
+        'city': project.city,
+        'state': project.state,
+        'ph_no': project.phone_num,
+        'email': request.user.email,
+        }
+
+    reviewer.email_user(subject=subject, message=message)
\ No newline at end of file