~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-10 02:28:26 UTC
  • mfrom: (13009.1.1 rollback-13003)
  • Revision ID: launchpad@pqm.canonical.com-20110510022826-j8km5oz3il95n93g
[rs=wgrant][rollback=13003] Roll back r13003. It gives indirect
 subscribers to private bugs with duplicates, crashing most operations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
961
961
        info = self.getSubscriptionInfo(level)
962
962
 
963
963
        if recipients is not None:
964
 
            # Pre-load duplicates
 
964
            # Pre-load duplicate bugs.
965
965
            list(self.duplicates)
966
966
            for subscription in info.duplicate_only_subscriptions:
967
967
                recipients.addDupeSubscriber(
968
968
                    subscription.person, subscription.bug)
969
 
            for subscription in info.structural_subscriptions_from_duplicates:
970
 
                recipients.addDupeSubscriber(
971
 
                    subscription.subscriber)
972
969
 
973
 
        unified_subscribers =(
974
 
            info.duplicate_only_subscriptions.subscribers.union(
975
 
                info.structural_subscriptions_from_duplicates.subscribers))
976
 
        return unified_subscribers.sorted
 
970
        return info.duplicate_only_subscriptions.subscribers.sorted
977
971
 
978
972
    def getSubscribersForPerson(self, person):
979
973
        """See `IBug."""
1042
1036
                                     include_master_dupe_subscribers=False):
1043
1037
        """See `IBug`."""
1044
1038
        recipients = BugNotificationRecipients(duplicateof=duplicateof)
1045
 
        # Call getDirectSubscribers to update the recipients list with direct
1046
 
        # subscribers.  The results of the method call are not used.
1047
1039
        self.getDirectSubscribers(recipients, level=level)
1048
1040
        if self.private:
1049
1041
            assert self.getIndirectSubscribers() == [], (
1050
1042
                "Indirect subscribers found on private bug. "
1051
1043
                "A private bug should never have implicit subscribers!")
1052
1044
        else:
1053
 
            # Call getIndirectSubscribers to update the recipients list with direct
1054
 
            # subscribers.  The results of the method call are not used.
1055
1045
            self.getIndirectSubscribers(recipients, level=level)
1056
1046
            if include_master_dupe_subscribers and self.duplicateof:
1057
1047
                # This bug is a public duplicate of another bug, so include
1918
1908
 
1919
1909
    def personIsAlsoNotifiedSubscriber(self, person):
1920
1910
        """See `IBug`."""
1921
 
        # This is here to avoid circular imports.
1922
 
        from lp.bugs.mail.bugnotificationrecipients import (
1923
 
            BugNotificationRecipients,
1924
 
            )
1925
 
 
1926
 
        def check_person_in_team(person, list_of_people):
1927
 
            """Is the person in one of the teams?
1928
 
 
1929
 
            Given a person and a list of people/teams, see if the person
1930
 
            belongs to one of the teams.
1931
 
            """
1932
 
            for subscriber in list_of_people:
1933
 
                if subscriber.is_team and person.inTeam(subscriber):
1934
 
                    return True
1935
 
            return False
1936
 
 
1937
1911
        # We have to use getAlsoNotifiedSubscribers() here and iterate
1938
1912
        # over what it returns because "also notified subscribers" is
1939
1913
        # actually a composite of bug contacts, structural subscribers
1944
1918
            return True
1945
1919
        # Otherwise check to see if the person is a member of any of the
1946
1920
        # subscribed teams.
1947
 
        if check_person_in_team(person, also_notified_subscribers):
1948
 
            return True
1949
 
 
1950
 
        direct_subscribers = self.getDirectSubscribers()
1951
 
        if check_person_in_team(person, direct_subscribers):
1952
 
            return True
1953
 
        duplicate_subscribers = self.getSubscribersFromDuplicates(
1954
 
            recipients=BugNotificationRecipients())
1955
 
        if check_person_in_team(person, duplicate_subscribers):
1956
 
            return True
 
1921
        for subscriber in also_notified_subscribers:
 
1922
            if subscriber.is_team and person.inTeam(subscriber):
 
1923
                return True
1957
1924
        return False
1958
1925
 
1959
1926
    def personIsSubscribedToDuplicate(self, person):
2313
2280
        return get_structural_subscriptions_for_bug(self.bug)
2314
2281
 
2315
2282
    @cachedproperty
2316
 
    @freeze(StructuralSubscriptionSet)
2317
 
    def structural_subscriptions_from_duplicates(self):
2318
 
        """Structural subscriptions from the bug's duplicates."""
2319
 
        self.duplicate_subscriptions.subscribers # Pre-load subscribers.
2320
 
        higher_precedence = (
2321
 
            self.direct_subscriptions.subscribers.union(
2322
 
                self.also_notified_subscribers))
2323
 
        all_duplicate_structural_subscriptions = list()
2324
 
        for duplicate in self.bug.duplicates:
2325
 
            duplicate_struct_subs = get_structural_subscriptions_for_bug(
2326
 
                duplicate)
2327
 
            all_duplicate_structural_subscriptions += duplicate_struct_subs
2328
 
        return (
2329
 
            subscription for subscription in
2330
 
                all_duplicate_structural_subscriptions
2331
 
                if subscription.subscriber not in higher_precedence)
2332
 
 
2333
 
    @cachedproperty
2334
2283
    @freeze(BugSubscriberSet)
2335
2284
    def all_assignees(self):
2336
2285
        """Assignees of the bug's tasks."""