[foundation-web] renewal-script: Make it not mail if there are no members needing renewal



commit 85ede4c945cc40722bf71c86c8e5702445dfd227
Author: Tobias Mueller <tobiasmue gnome org>
Date:   Fri Nov 23 22:13:11 2012 +0100

    renewal-script: Make it not mail if there are no members needing renewal

 bin/mail_renewals_to_foundation_list.py |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/bin/mail_renewals_to_foundation_list.py b/bin/mail_renewals_to_foundation_list.py
index 19eb7cf..22d576e 100755
--- a/bin/mail_renewals_to_foundation_list.py
+++ b/bin/mail_renewals_to_foundation_list.py
@@ -60,18 +60,22 @@ def main(options=None):
 
 
     members = get_members_which_need_renewal('month')
-    emailtext = format_members_for_mail(members)
+    if not members:
+        log.warn('No one needs renewals! :-)')
     
-    today = datetime.date.today()
-    subject = "Memberships needing renewal (%s)" % today.strftime("%02Y-%02m")
-    
-    if sendmail:
-        log.warn('Sending mail to %s: %s', to, subject)
-        send_email(to, subject, emailtext)
-    else:
-        log.info('Not sending mail to %s', to)
-        log.info('%s', subject)
-        log.info('%s', emailtext)
+    else: # We do have members
+        emailtext = format_members_for_mail(members)
+        
+        today = datetime.date.today()
+        subject = "Memberships needing renewal (%s)" % today.strftime("%02Y-%02m")
+        
+        if sendmail:
+            log.warn('Sending mail to %s: %s', to, subject)
+            send_email(to, subject, emailtext)
+        else:
+            log.info('Not sending mail to %s', to)
+            log.info('%s', subject)
+            log.info('%s', emailtext)
     
     return 0
     



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]