Send out notifications and emails to admin and backup admin
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 12 Apr 2009 12:31:55 +0000
changeset 2170 cec46675f866
parent 2169 79bb965e723a
child 2171 83d96aadd228
Send out notifications and emails to admin and backup admin Patch by: Sverre Rabbelier
app/soc/logic/helper/notifications.py
app/soc/views/models/org_app.py
--- a/app/soc/logic/helper/notifications.py	Sun Apr 12 12:31:23 2009 +0000
+++ b/app/soc/logic/helper/notifications.py	Sun Apr 12 12:31:55 2009 +0000
@@ -104,8 +104,6 @@
     entity : An accepted group application
   """
 
-  to_user = entity.applicant
-
   url = "http://%(host)s%(redirect)s" % {
       'redirect': redirects.getApplicantRedirect(entity,
       {'url_name': params['group_url_name']}),
@@ -126,7 +124,8 @@
 
   template = DEF_NEW_GROUP_TEMPLATE
 
-  sendNotification(to_user, None, message_properties, subject, template)
+  for to in [entity.applicant, entity.backup_admin]:
+    sendNotification(to, None, message_properties, subject, template)
 
 
 def sendNewReviewNotification(to_user, review, reviewed_name, redirect_url):
--- a/app/soc/views/models/org_app.py	Sun Apr 12 12:31:23 2009 +0000
+++ b/app/soc/views/models/org_app.py	Sun Apr 12 12:31:55 2009 +0000
@@ -222,15 +222,15 @@
         (sender_name, sender) = default_sender
 
       # construct the contents of the email
-      user_entity = app_entity.applicant
-      to = accounts.denormalizeAccount(user_entity.account).email()
+      admin_entity = app_entity.applicant
+      backup_entity = app_entity.backup_admin
 
-      context = {'sender': sender,
-              'to': to,
-              'sender_name': sender_name,
-              'to_name': user_entity.name,
-              'program_name': app_entity.scope.name,
-              'org_app_name': app_entity.name}
+      context = {
+          'sender': sender,
+          'sender_name': sender_name,
+          'program_name': app_entity.scope.name,
+          'org_app_name': app_entity.name
+          }
 
       if status == 'accepted':
         # use the accepted template and subject
@@ -242,8 +242,13 @@
         template = params['rejected_mail_template']
         context['subject'] = 'Thank you for your application'
 
-      # send out the constructed email
-      mail_dispatcher.sendMailFromTemplate(template, context)
+      for to in [admin_entity, backup_entity]:
+        email = accounts.denormalizeAccount(to.account).email()
+        context['to'] = email
+        context['to_name'] = to.name
+
+        # send out the constructed email
+        mail_dispatcher.sendMailFromTemplate(template, context)
 
   @decorators.merge_params
   @decorators.check_access