~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from zope.interface import implements
12
12
from zope.proxy import sameProxiedObjects
13
13
 
14
 
from lp.bugs.enum import BugNotificationLevel
15
14
from lp.bugs.model.bugsubscription import BugSubscription
16
 
from lp.bugs.model.bug import Bug
 
15
from lp.bugs.model.bug import Bug, BugMute
17
16
from lp.bugs.interfaces.personsubscriptioninfo import (
18
17
    IAbstractSubscriptionInfoCollection,
19
18
    IRealSubscriptionInfoCollection,
219
218
                    pillar.security_contact, pillar.bug_supervisor)
220
219
        return (direct, duplicates)
221
220
 
 
221
    def _isMuted(self, person, bug):
 
222
        store = Store.of(person)
 
223
        mutes = store.find(
 
224
            BugMute,
 
225
            BugMute.bug == bug,
 
226
            BugMute.person == person)
 
227
        is_muted = mutes.one()
 
228
        if is_muted is None:
 
229
            return False
 
230
        else:
 
231
            return True
 
232
 
222
233
    def loadSubscriptionsFor(self, person, bug):
223
234
        self.person = person
224
235
        self.administrated_teams = person.getAdministratedTeams()
228
239
        direct, from_duplicate = (
229
240
            self._getDirectAndDuplicateSubscriptions(person, bug))
230
241
 
 
242
        # Then get the 'muted' flag.
 
243
        self.muted = self._isMuted(person, bug)
 
244
 
231
245
        # Then get owner and assignee virtual subscriptions.
232
246
        as_owner = VirtualSubscriptionInfoCollection(
233
247
            self.person, self.administrated_teams)
241
255
            assignee = bugtask.assignee
242
256
            if person.inTeam(assignee):
243
257
                as_assignee.add(assignee, bug, pillar, bugtask)
244
 
        self.muted = bool(
245
 
            direct.personal and
246
 
            direct.personal[0].subscription.bug_notification_level
247
 
                == BugNotificationLevel.NOTHING)
248
258
        self.count = 0
249
259
        for name, collection in (
250
260
            ('direct', direct), ('from_duplicate', from_duplicate),