~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/personnotification.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-19 09:35:32 UTC
  • mfrom: (13082.1.3 bug-784948)
  • Revision ID: launchpad@pqm.canonical.com-20110519093532-ig34h74kzmqb2ejj
[r=lifeless,
 stevenk][bug=784948] PersonNotificationManager.sendNotifications
 won't crash when sending email to admins of a team without a contact address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        """See `IPersonNotification`."""
63
63
        return len(self.to_addresses) > 0
64
64
 
65
 
    def send(self):
 
65
    def send(self, logger=None):
66
66
        """See `IPersonNotification`."""
67
67
        if not self.can_send:
68
68
            raise AssertionError(
69
69
                "Can't send a notification to a person without an email.")
 
70
        to_addresses = self.to_addresses
 
71
        if logger:
 
72
            logger.info("Sending notification to %r." % to_addresses)
70
73
        from_addr = config.canonical.bounce_address
71
 
        simple_sendmail(from_addr, self.to_addresses, self.subject, self.body)
 
74
        simple_sendmail(from_addr, to_addresses, self.subject, self.body)
72
75
        self.date_emailed = datetime.now(pytz.timezone('UTC'))
73
76
 
74
77