~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/subscribers/bug.py

[r=stevenk][bug=52915] Notify new project maintainer when a private
        bugtask is re-targetted to the project.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from canonical.launchpad.webapp.publisher import canonical_url
23
23
from lp.bugs.adapters.bugchange import (
24
24
    BugDuplicateChange,
 
25
    BugTaskTargetChange,
25
26
    BugTaskAssigneeChange,
26
27
    get_bug_changes,
27
28
    )
32
33
from lp.bugs.mail.newbug import generate_bug_add_email
33
34
from lp.bugs.model.bug import get_also_notified_subscribers
34
35
from lp.registry.interfaces.person import IPerson
 
36
from lp.registry.interfaces.product import IProduct
35
37
from lp.services.mail.sendmail import (
36
38
    format_address,
37
39
    sendmail,
171
173
                        level=change.change_level,
172
174
                        include_master_dupe_subscribers=False))
173
175
                recipients.update(change_recipients)
 
176
            # Additionally, if we are re-targetting a bugtask for a private
 
177
            # bug, we need to ensure the new bug supervisor and maintainer are
 
178
            # notified (if they can view the bug).
 
179
            # If they are the same person, only send one notification.
 
180
            if (isinstance(change, BugTaskTargetChange) and
 
181
                  old_bugtask is not None and bug_delta.bug.private):
 
182
                bugtask_deltas = bug_delta.bugtask_deltas
 
183
                if not isinstance(bugtask_deltas, (list, tuple)):
 
184
                    bugtask_deltas = [bugtask_deltas]
 
185
                for bugtask_delta in bugtask_deltas:
 
186
                    if not bugtask_delta.target:
 
187
                        continue
 
188
                    new_target = bugtask_delta.bugtask.target
 
189
                    if not new_target or not IProduct.providedBy(new_target):
 
190
                        continue
 
191
                    if bug_delta.bug.userCanView(new_target.owner):
 
192
                        recipients.addMaintainer(new_target.owner)
 
193
                    if (new_target.bug_supervisor and not
 
194
                        new_target.bug_supervisor.inTeam(new_target.owner) and
 
195
                        bug_delta.bug.userCanView(new_target.bug_supervisor)):
 
196
                            recipients.addBugSupervisor(
 
197
                                new_target.bug_supervisor)
174
198
            bug_delta.bug.addChange(change, recipients=recipients)
175
199
 
176
200