def test_subscriber_is_reporter(self): self.bug = self.factory.makeBug(owner=self.subscriber) self.subscriptions = PersonSubscriptions(self.subscriber, self.bug) # Subscribed directly to the bug. with person_logged_in(self.subscriber): self.bug.subscribe(self.subscriber, self.subscriber) # Load a `PersonSubscriptionInfo`s for subscriber and a bug. self.subscriptions.reload() self.assertRealSubscriptionInfoMatches( self.subscriptions.direct.personal[0], self.bug, self.subscriber, True, [])
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 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 setUp(self): super(TestPersonSubscriptionInfo, self).setUp() self.subscriber = self.factory.makePerson() self.bug = self.factory.makeBug() self.subscriptions = PersonSubscriptions(self.subscriber, self.bug)