~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

[r=sinzui][bug=702429] Bugtask pillar owners can see private bugs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
from lp.bugs.model.bugtask import (
171
171
    BugTask,
172
172
    bugtask_sort_key,
 
173
    get_bug_privacy_filter
173
174
    )
174
175
from lp.bugs.model.bugwatch import BugWatch
175
176
from lp.bugs.model.structuralsubscription import (
2602
2603
        if duplicateof:
2603
2604
            where_clauses.append("Bug.duplicateof = %d" % duplicateof.id)
2604
2605
 
2605
 
        admins = getUtility(ILaunchpadCelebrities).admin
2606
 
        if user:
2607
 
            if not user.inTeam(admins):
2608
 
                # Enforce privacy-awareness for logged-in, non-admin users,
2609
 
                # so that they can only see the private bugs that they're
2610
 
                # allowed to see.
2611
 
                where_clauses.append("""
2612
 
                    (Bug.private = FALSE OR
2613
 
                      Bug.id in (
2614
 
                         -- Users who have a subscription to this bug.
2615
 
                         SELECT BugSubscription.bug
2616
 
                           FROM BugSubscription, TeamParticipation
2617
 
                           WHERE
2618
 
                             TeamParticipation.person = %(personid)s AND
2619
 
                             BugSubscription.person = TeamParticipation.team
2620
 
                         UNION
2621
 
                         -- Users who are the assignee for one of the bug's
2622
 
                         -- bugtasks.
2623
 
                         SELECT BugTask.bug
2624
 
                           FROM BugTask, TeamParticipation
2625
 
                           WHERE
2626
 
                             TeamParticipation.person = %(personid)s AND
2627
 
                             TeamParticipation.team = BugTask.assignee
2628
 
                      )
2629
 
                    )""" % sqlvalues(personid=user.id))
2630
 
        else:
2631
 
            # Anonymous user; filter to include only public bugs in
2632
 
            # the search results.
2633
 
            where_clauses.append("Bug.private = FALSE")
 
2606
        privacy_filter = get_bug_privacy_filter(user)
 
2607
        if privacy_filter:
 
2608
            where_clauses.append(privacy_filter)
2634
2609
 
2635
2610
        other_params = {}
2636
2611
        if orderBy: