110
110
from lp.bugs.interfaces.bugwatch import IBugWatchSet
111
111
from lp.bugs.interfaces.cve import ICveSet
112
112
from lp.bugs.mail.bugnotificationbuilder import format_rfc2822_date
113
from lp.bugs.model.personsubscriptioninfo import PersonSubscriptions
113
114
from lp.bugs.model.structuralsubscription import (
114
115
get_structural_subscriptions_for_bug,
116
from lp.bugs.model.personsubscriptioninfo import PersonSubscriptions
117
117
from lp.services.fields import DuplicateBug
118
118
from lp.services.propertycache import cachedproperty
664
664
LaunchpadView.initialize(self)
665
665
cache = IJSONRequestCache(self.request).objects
666
666
self.extractBugSubscriptionDetails(self.user, self.context, cache)
667
cache['bug_is_private'] = self.context.private
668
669
cache['notifications_text'] = self.notifications_text
849
850
data = dict(data)
851
852
# We handle privacy changes by hand instead of leaving it to
852
# the usual machinery because we must use bug.setPrivate() to
853
# ensure auditing information is recorded.
853
# the usual machinery because we must use
854
# bug.setPrivacyAndSecurityRelated() to ensure auditing information is
854
856
bug = self.context.bug
855
bug_before_modification = Snapshot(
856
bug, providing=providedBy(bug))
857
857
private = data.pop('private')
858
858
user_will_be_subscribed = (
859
859
private and bug.getSubscribersForPerson(self.user).is_empty())
860
860
security_related = data.pop('security_related')
861
private_changed = bug.setPrivate(
862
private, getUtility(ILaunchBag).user)
863
security_related_changed = bug.setSecurityRelated(security_related)
864
if private_changed or security_related_changed:
867
changed_fields.append('private')
868
self._handlePrivacyChanged(user_will_be_subscribed)
869
if security_related_changed:
870
changed_fields.append('security_related')
871
notify(ObjectModifiedEvent(
872
bug, bug_before_modification, changed_fields))
861
user = getUtility(ILaunchBag).user
862
(private_changed, security_related_changed) = (
863
bug.setPrivacyAndSecurityRelated(private, security_related, user))
865
self._handlePrivacyChanged(user_will_be_subscribed)
873
866
if self.request.is_ajax:
874
867
if private_changed or security_related_changed:
875
868
return self._getSubscriptionDetails()
889
882
bug = self.context
890
883
subscribers_portlet = BugPortletSubscribersWithDetails(
891
884
bug, self.request)
892
subscription_data = subscribers_portlet()
894
cache, cls=ResourceJSONEncoder,
885
subscription_data = subscribers_portlet.subscriber_data
888
subscription_data=subscription_data)
889
self.request.response.setHeader('content-type', 'application/json')
891
result_data, cls=ResourceJSONEncoder,
895
892
media_type=EntryResource.JSON_TYPE)
899
"subscription_data": %s}
900
""" % (cache_data, subscription_data)
902
894
def _handlePrivacyChanged(self, user_will_be_subscribed):
903
895
"""Handle the case where the privacy of the bug has been changed.