← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/information_type-model into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/information_type-model into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/information_type-model/+merge/97319

Add the new information_type column to the model for Bug.

I'm not certain if setting the default on the EnumCol is the right thing to do, but it seems to work. information_type will be set for new bugs, or bugs that change their privacy or security related flag. Population of the type will be finished off with a garbo job in a separate branch.
-- 
https://code.launchpad.net/~stevenk/launchpad/information_type-model/+merge/97319
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/information_type-model into lp:launchpad.
=== modified file 'lib/lp/bugs/interfaces/bug.py'
--- lib/lp/bugs/interfaces/bug.py	2012-03-08 11:51:59 +0000
+++ lib/lp/bugs/interfaces/bug.py	2012-03-13 22:58:22 +0000
@@ -82,6 +82,7 @@
 from lp.bugs.interfaces.bugwatch import IBugWatch
 from lp.bugs.interfaces.cve import ICve
 from lp.code.interfaces.branchlink import IHasLinkedBranches
+from lp.registry.enums import InformationType
 from lp.registry.interfaces.person import IPerson
 from lp.services.fields import (
     BugField,
@@ -211,6 +212,12 @@
                            "their subscribers."),
              default=False,
              readonly=True))
+    information_type = exported(
+        Choice(
+            title=_('Information Type'), vocabulary=InformationType,
+            required=False, readonly=True,
+            description=_(
+                'The type of information contained in this bug report.')))
 
     def userCanView(user):
         """Return True if `user` can see this IBug, false otherwise."""
@@ -431,7 +438,6 @@
     def hasBranch(branch):
         """Is this branch linked to this bug?"""
 
-
     def isSubscribed(person):
         """Is person subscribed to this bug?
 
@@ -682,7 +688,7 @@
         :param end_date: The latest date for which activity can be
             returned.
         """
-    
+
     def shouldConfirmBugtasks():
         """Should we try to confirm this bug's bugtasks?
 

=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py	2012-03-13 00:45:33 +0000
+++ lib/lp/bugs/model/bug.py	2012-03-13 22:58:22 +0000
@@ -157,6 +157,7 @@
     )
 from lp.code.interfaces.branchcollection import IAllBranches
 from lp.hardwaredb.interfaces.hwdb import IHWSubmissionBugSet
+from lp.registry.enums import InformationType
 from lp.registry.interfaces.distribution import IDistribution
 from lp.registry.interfaces.distroseries import IDistroSeries
 from lp.registry.interfaces.person import (
@@ -180,6 +181,7 @@
 from lp.services.database.constants import UTC_NOW
 from lp.services.database.datetimecol import UtcDateTimeCol
 from lp.services.database.decoratedresultset import DecoratedResultSet
+from lp.services.database.enumcol import EnumCol
 from lp.services.database.lpstorm import IStore
 from lp.services.database.sqlbase import (
     cursor,
@@ -351,6 +353,8 @@
         dbName='who_made_private', foreignKey='Person',
         storm_validator=validate_public_person, default=None)
     security_related = BoolCol(notNull=True, default=False)
+    information_type = EnumCol(
+        enum=InformationType, default=InformationType.PUBLIC)
 
     # useful Joins
     activity = SQLMultipleJoin('BugActivity', joinColumn='bug', orderBy='id')
@@ -1693,6 +1697,16 @@
 
         return bugtask
 
+    def _setInformationType(self):
+        if self.private and self.security_related:
+            self.information_type = InformationType.EMBARGOEDSECURITY
+        elif self.private:
+            self.information_type = InformationType.USERDATA
+        elif self.security_related:
+            self.information_type = InformationType.UNEMBARGOEDSECURITY
+        else:
+            self.information_type = InformationType.PUBLIC
+
     def setPrivacyAndSecurityRelated(self, private, security_related, who):
         """ See `IBug`."""
         private_changed = False
@@ -1743,6 +1757,8 @@
             # to wait for the next calculation job for the adjusted heat.
             self.updateHeat()
 
+        self._setInformationType()
+
         if private_changed or security_related_changed:
             changed_fields = []
 
@@ -2842,6 +2858,8 @@
         if notify_event:
             notify(event)
 
+        bug._setInformationType()
+
         # Calculate the bug's initial heat.
         bug.updateHeat()
 

=== modified file 'lib/lp/bugs/model/tests/test_bug.py'
--- lib/lp/bugs/model/tests/test_bug.py	2012-03-13 00:45:33 +0000
+++ lib/lp/bugs/model/tests/test_bug.py	2012-03-13 22:58:22 +0000
@@ -29,6 +29,7 @@
     )
 from lp.bugs.model.bugnotification import BugNotificationRecipient
 from lp.bugs.scripts.bugnotification import get_email_notifications
+from lp.registry.enums import InformationType
 from lp.registry.interfaces.person import PersonVisibility
 from lp.services.database.lpstorm import IStore
 from lp.services.features.testing import FeatureFixture
@@ -916,6 +917,57 @@
             bug.setPrivacyAndSecurityRelated(True, False, bug.owner)
             self.assertTrue(bug.private)
 
+    def test_bug_information_type(self):
+        # Bugs have the correct corresponding information type.
+        bug = self.factory.makeBug()
+        private_bug = self.factory.makeBug(private=True)
+        private_sec_bug = self.factory.makeBug(
+            private=True, security_related=True)
+        mapping = (
+            (bug, InformationType.PUBLIC),
+            (private_bug, InformationType.USERDATA),
+            (private_sec_bug, InformationType.EMBARGOEDSECURITY),
+            )
+        [self.assertEqual(m[1], m[0].information_type) for m in mapping]
+
+    def test_private_to_public_information_type(self):
+        # A private bug transitioning to public has the correct information
+        # type.
+        owner = self.factory.makePerson()
+        bug = self.factory.makeBug(private=True, owner=owner)
+        with person_logged_in(owner):
+            bug.setPrivate(False, owner)
+        self.assertEqual(InformationType.PUBLIC, bug.information_type)
+
+    def test_private_sec_to_public_sec_information_type(self):
+        # A private security bug transitioning to public security has the
+        # correct information type.
+        owner = self.factory.makePerson()
+        bug = self.factory.makeBug(
+            private=True, security_related=True, owner=owner)
+        with person_logged_in(owner):
+            bug.setPrivate(False, owner)
+        self.assertEqual(
+            InformationType.UNEMBARGOEDSECURITY, bug.information_type)
+
+    def test_private_sec_to_public_information_type(self):
+        # A private security bug transitioning to public has the correct
+        # information type.
+        owner = self.factory.makePerson()
+        bug = self.factory.makeBug(
+            private=True, security_related=True, owner=owner)
+        with person_logged_in(owner):
+            bug.setPrivacyAndSecurityRelated(False, False, owner)
+        self.assertEqual(InformationType.PUBLIC, bug.information_type)
+
+    def test_public_to_private_information_type(self):
+        # A public bug transitioning to private has the correct information
+        # type.
+        bug = self.factory.makeBug()
+        with person_logged_in(bug.owner):
+            bug.setPrivate(True, bug.owner)
+        self.assertEqual(InformationType.USERDATA, bug.information_type)
+
 
 class TestBugPrivateAndSecurityRelatedUpdatesPrivateProject(
         TestBugPrivateAndSecurityRelatedUpdatesMixin, TestCaseWithFactory):


Follow ups