def initialize(self): super(BugSubscriptionListView, self).initialize() subscriptions = list( get_structural_subscriptions_for_bug(self.context.bug, self.user)) expose_structural_subscription_data_to_js(self.context, self.request, self.user, subscriptions) subscriptions_info = PersonSubscriptions(self.user, self.context.bug) subdata, references = subscriptions_info.getDataForClient() cache = IJSONRequestCache(self.request).objects cache.update(references) cache['bug_subscription_info'] = subdata cache['bug_is_private'] = self.context.bug.private
def initialize(self): super(BugSubscriptionListView, self).initialize() subscriptions = list(get_structural_subscriptions_for_bug( self.context.bug, self.user)) expose_structural_subscription_data_to_js( self.context, self.request, self.user, subscriptions) subscriptions_info = PersonSubscriptions( self.user, self.context.bug) subdata, references = subscriptions_info.getDataForClient() cache = IJSONRequestCache(self.request).objects cache.update(references) cache['bug_subscription_info'] = subdata cache['bug_is_private'] = self.context.bug.private
def test_subscriptions_from_parent(self): # get_structural_subscriptions_for_bug() will return any # structural subscriptions from the parents of the targets of # that bug. project = self.factory.makeProject() product = self.factory.makeProduct(project=project, owner=project.owner) subscriber = self.factory.makePerson() self_sub = project.addBugSubscription(subscriber, subscriber) # This is a sanity check. self.assertEqual(project, product.parent_subscription_target) bug = self.factory.makeBug(target=product) subscriptions = get_structural_subscriptions_for_bug(bug, subscriber) self.assertEqual(set([self_sub]), set(subscriptions))
def test_subscriptions_from_parent(self): # get_structural_subscriptions_for_bug() will return any # structural subscriptions from the parents of the targets of # that bug. project = self.factory.makeProject() product = self.factory.makeProduct( project=project, owner=project.owner) subscriber = self.factory.makePerson() self_sub = project.addBugSubscription(subscriber, subscriber) # This is a sanity check. self.assertEqual(project, product.parent_subscription_target) bug = self.factory.makeBug(target=product) subscriptions = get_structural_subscriptions_for_bug( bug, subscriber) self.assertEqual(set([self_sub]), set(subscriptions))
def extractBugSubscriptionDetails(self, user, bug, cache): # We are using "direct" to represent both direct and personal # (not team). self.direct_notifications = False self.direct_all_notifications = False self.direct_metadata_notifications = False self.direct_lifecycle_notifications = False self.other_subscription_notifications = False self.only_other_subscription_notifications = False self.any_subscription_notifications = False self.muted = False if user is not None: has_structural_subscriptions = not ( get_structural_subscriptions_for_bug(bug, user).is_empty()) self.muted = bug.isMuted(user) psi = PersonSubscriptions(user, bug) if psi.direct.personal: self.direct_notifications = True direct = psi.direct.personal[0] cache['subscription'] = direct.subscription level = direct.subscription.bug_notification_level if level == BugNotificationLevel.COMMENTS: self.direct_all_notifications = True elif level == BugNotificationLevel.METADATA: self.direct_metadata_notifications = True else: assert level == BugNotificationLevel.LIFECYCLE self.direct_lifecycle_notifications = True self.other_subscription_notifications = bool( has_structural_subscriptions or psi.from_duplicate.count or psi.as_owner.count or psi.as_assignee.count or psi.direct.as_team_member or psi.direct.as_team_admin) cache['other_subscription_notifications'] = bool( self.other_subscription_notifications) self.only_other_subscription_notifications = ( self.other_subscription_notifications and not self.direct_notifications) self.any_subscription_notifications = ( self.other_subscription_notifications or self.direct_notifications) self.user_should_see_mute_link = ( self.any_subscription_notifications or self.muted)
def getSubscriptions(self, person=None): result = get_structural_subscriptions_for_bug(self.bug, person) self.assertTrue(is_security_proxied_or_harmless(result)) return result