def _send_update_notice(self, action, actor, orig_status=None, additions=None, removals=None, file=None, fileid=None, lower=string.lower): """Send email notification about issue event to relevant parties.""" action = string.capitalize(string.split(action, '_')[0]) new_status = self.status() recipients = [] # Who to notify: # # We want to noodge only assigned supporters while it's being worked # on, ie assigned supporters are corresponding about it. Otherwise, # either the dispatchers (managers) and assigned supporters get # notices, or everyone gets notices, depending on the collector's # .dispatching setting: # # - Requester always # - Person taking action always # - Supporters assigned to the issue always # - Managers or managers + all supporters (according to dispatching): # - When in any state besides accepted (or accepted_confidential) # - When being accepted (or accepted_confidential) # - When is accepted (or accepted_confidential) and moving to # another state # - Any supporters being removed from the issue by the current action # - In addition, any destinations for the resulting state registered # in state_email are included. # # We're liberal about allowing duplicates in the collection phase - # all duplicate addresses will be filtered out before actual send. candidates = [self.submitter_id, actor] + list(self.assigned_to()) continuing_accepted = (orig_status and lower(orig_status) in ['accepted', 'accepted_confidential'] and lower(new_status) in ['accepted', 'accepted_confidential']) if orig_status and not continuing_accepted: candidates.extend(self.aq_parent.managers) if not self.aq_parent.dispatching: candidates.extend(self.aq_parent.supporters) else: candidates.extend(self.assigned_to()) if removals: # Notify supporters being removed from the issue (confirms # their action, if they're resigning, and informs them if # manager is deassigning them). candidates.extend(removals) didids = []; gotemails = [] for userid in candidates: if userid in didids: # Cull duplicates. continue didids.append(userid) name, email = util.get_email_fullname(self, userid) if (userid == self.submitter_id) and self.submitter_email: if self.submitter_email == email: # Explicit one same as user preference - clear the # explicit, so issue notification destination will track # changes to the preference. self.submitter_email = None else: # Explicitly specified email overrides user pref email. email = self.submitter_email if self.submitter_name: name = self.submitter_name if email: if email in gotemails: continue gotemails.append(email) recipients.append((name, email)) if (self.state_email.has_key(new_status) and self.state_email[new_status]): for addr in re.split(", *| +", self.state_email[new_status]): se = ("_%s_ recipient" % new_status, addr) candidates.append(se) # For recipients-debug if addr not in recipients: recipients.append(se) if recipients: to = ", ".join(['"%s" <%s>' % (name, email) for name, email in recipients]) title = self.aq_parent.title[:50] short_title = " ".join(title[:40].split(" ")[:-1]) or title if short_title != title[:40]: short_title = short_title + " ..." sender = ('"Collector: %s" <%s>' % (short_title, self.aq_parent.email)) if '.' in title or ',' in title: title = '"%s"' % title if self.abbrev: subject = "[%s]" % self.abbrev else: subject = "[Collector]" subject = ('%s %s/%2d %s "%s"' % (subject, self.id, self.action_number, string.capitalize(action), self.title)) body = self.get_transcript().text body = uploadexp.sub(r'\1 "\2"\n - %s/\2/view' % self.absolute_url(), body) cin = self.collector_issue_notice message = cin(sender=sender, recipients=to, subject=subject, issue_id=self.id, action=action, actor=actor, number=self.action_number, security_related=self.security_related, confidential=self.confidential(), title=self.title, submitter_name=self.submitter_name, status=new_status, klass=self.classification, topic=self.topic, importance=self.importance, issue_url=self.absolute_url(), body=body, candidates=candidates) mh = self.MailHost try: mh.send(message) except: import sys return "Email notice error: '%s'" % str(sys.exc_info()[1])
def _send_update_notice(self, action, actor, orig_status=None, additions=None, removals=None, file=None, fileid=None): """Send email notification about issue event to relevant parties.""" action = string.capitalize(string.split(action, '_')[0]) new_status = string.split(self.status(), '_')[0] recipients = [] # Who to notify: # # We want to noodge only assigned supporters while it's being worked # on, ie assigned supporters are corresponding about it. Otherwise, # either the dispatchers (managers) and assigned supporters get # notices, or everyone gets notices, depending on the collector's # .dispatching setting: # # - Requester always # - Person taking action always # - Supporters assigned to the issue always # - Managers or managers + all supporters (according to dispatching): # - When an issue is any state besides accepted # - When an issue is being accepted # - When an issue is accepted and moving to another state # - Any supporters being removed from the issue by the current action # # We're liberal about duplicates - they'll be filtered before send. candidates = [self.submitter_id, actor] + list(self.assigned_to()) if orig_status and not ('accepted' == string.lower(new_status) == string.lower(orig_status)): candidates.extend(self.aq_parent.managers) if not self.aq_parent.dispatching: candidates.extend(self.aq_parent.supporters) else: candidates.extend(self.assigned_to()) if removals: # Notify supporters being removed from the issue (confirms # their action, if they're resigning, and informs them if # manager is deassigning them). candidates.extend(removals) didids = [] gotemails = [] for userid in candidates: if userid in didids: # Cull duplicates. continue didids.append(userid) name, email = util.get_email_fullname(self, userid) if (userid == self.submitter_id) and self.submitter_email: if self.submitter_email == email: # Explicit one same as user preference - clear the # explicit, so issue notification destination will track # changes to the preference. self.submitter_email = None else: # Explicitly specified email overrides user pref email. email = self.submitter_email if self.submitter_name: name = self.submitter_name if email: if email in gotemails: continue gotemails.append(email) recipients.append((name, email)) if recipients: to = ", ".join( ["%s <%s>" % (name, email) for name, email in recipients]) title = self.aq_parent.title[:50] short_title = " ".join(title[:40].split(" ")[:-1]) or title if short_title != title[:40]: short_title = short_title + " ..." sender = ('"Collector: %s" <%s>' % (short_title, self.aq_parent.email)) if '.' in title or ',' in title: title = '"%s"' % title if self.abbrev: subject = "[%s]" % self.abbrev else: subject = "[Collector]" subject = ('%s %s/%2d %s "%s"' % (subject, self.id, self.action_number, string.capitalize(action), self.title)) body = self.get_transcript().text body = uploadexp.sub( r'\1 "\2"\n - %s/\2/view' % self.absolute_url(), body) cin = self.collector_issue_notice message = cin(sender=sender, recipients=to, subject=subject, issue_id=self.id, action=action, actor=actor, number=self.action_number, security_related=self.security_related, confidential=self.confidential(), title=self.title, submitter_name=self.submitter_name, status=new_status, klass=self.classification, topic=self.topic, importance=self.importance, issue_url=self.absolute_url(), body=body, candidates=candidates) mh = self.MailHost try: mh.send(message) except: import sys err = sys.exc_info() return "Email notice error: '%s'" % str(err[1])