← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/blueprint-info-type-code into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/blueprint-info-type-code into lp:launchpad with lp:~abentley/launchpad/blueprint-info-type-idx as a prerequisite.

Requested reviews:
  Aaron Bentley (abentley)
  Stuart Bishop (stub)
  Canonical Launchpad Engineering (launchpad)

For more details, see:
https://code.launchpad.net/~abentley/launchpad/blueprint-info-type-code/+merge/121683

= Summary =
Tweak the  model code and garbo job for Specification.information_type

== Pre-implementation notes ==
None

== LOC Rationale ==
Part of Private projects

== Implementation details ==
Specification already had a .private member, which abel has masked with a property.  Since this member is unused, we can simply drop it (and later, the column).

This also fixes the documentation and default for the interface.

== Tests ==
None

== Demo and Q/A ==
None

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  database/schema/patch-2209-28-1.sql
  database/schema/comments.sql
  database/schema/security.cfg
  lib/lp/scripts/garbo.py
  lib/lp/blueprints/model/specification.py
  lib/lp/scripts/tests/test_garbo.py
  database/schema/patch-2209-28-2.sql
  lib/lp/blueprints/interfaces/specification.py
-- 
https://code.launchpad.net/~abentley/launchpad/blueprint-info-type-code/+merge/121683
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2012-08-25 06:25:53 +0000
+++ database/schema/security.cfg	2012-08-28 19:12:35 +0000
@@ -2273,6 +2273,7 @@
 public.sourcepackagename                = SELECT
 public.sourcepackagerelease             = SELECT
 public.sourcepackagepublishinghistory   = SELECT, UPDATE
+public.specification                    = SELECT, UPDATE
 public.suggestivepotemplate             = INSERT, DELETE
 public.teamparticipation                = SELECT, DELETE
 public.translationmessage               = SELECT, DELETE

=== modified file 'lib/lp/blueprints/interfaces/specification.py'
--- lib/lp/blueprints/interfaces/specification.py	2012-08-20 16:38:10 +0000
+++ lib/lp/blueprints/interfaces/specification.py	2012-08-28 19:12:35 +0000
@@ -155,6 +155,7 @@
 
     id = Int(title=_("Database ID"), required=True, readonly=True)
 
+<<<<<<< TREE
     information_type = exported(
         Choice(
             title=_('Information Type'), vocabulary=InformationType,
@@ -172,6 +173,15 @@
     the permission launchpad.LimitedView.
     """
 
+=======
+    information_type = exported(
+        Choice(
+            title=_('Information Type'), vocabulary=InformationType,
+            required=True, readonly=True, default=InformationType.PUBLIC,
+            description=_(
+                'The type of information contained in this specification.')))
+
+>>>>>>> MERGE-SOURCE
     name = exported(
         SpecNameField(
             title=_('Name'), required=True, readonly=False,

=== modified file 'lib/lp/blueprints/model/specification.py'
--- lib/lp/blueprints/model/specification.py	2012-08-20 16:38:10 +0000
+++ lib/lp/blueprints/model/specification.py	2012-08-28 19:12:35 +0000
@@ -73,6 +73,7 @@
     )
 from lp.registry.interfaces.distribution import IDistribution
 from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.registry.enums import InformationType
 from lp.registry.interfaces.person import validate_public_person
 from lp.registry.interfaces.product import IProduct
 from lp.registry.interfaces.productseries import IProductSeries
@@ -126,6 +127,9 @@
     _defaultOrder = ['-priority', 'definition_status', 'name', 'id']
 
     # db field names
+
+    information_type = EnumCol(
+        enum=InformationType, default=InformationType.PUBLIC)
     name = StringCol(unique=True, notNull=True)
     title = StringCol(notNull=True)
     summary = StringCol(notNull=True)

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2012-08-22 23:27:31 +0000
+++ lib/lp/scripts/garbo.py	2012-08-28 19:12:35 +0000
@@ -27,6 +27,7 @@
 import iso8601
 from psycopg2 import IntegrityError
 import pytz
+<<<<<<< TREE
 from storm.expr import (
     And,
     Exists,
@@ -35,6 +36,13 @@
     Select,
     Update,
     Or)
+=======
+from storm.expr import (
+    In,
+    Select,
+    Update,
+    )
+>>>>>>> MERGE-SOURCE
 from storm.locals import (
     Max,
     Min,
@@ -46,6 +54,7 @@
 from zope.security.proxy import removeSecurityProxy
 
 from lp.answers.model.answercontact import AnswerContact
+from lp.blueprints.model.specification import Specification
 from lp.bugs.interfaces.bug import IBugSet
 from lp.bugs.interfaces.bugtarget import (
     POLICY_ALLOWED_TYPES as BUG_POLICY_ALLOWED_TYPES,
@@ -951,6 +960,32 @@
         self.done = True
 
 
+class SpecificationInformationTypeDefault(TunableLoop):
+    """Set all Specification.information_type to Public (default)."""
+    maximum_chunk_size = 1000
+
+    def __init__(self, log, abort_time=None):
+        super(SpecificationInformationTypeDefault, self).__init__(log,
+                                                                  abort_time)
+        self.rows_updated = None
+        self.store = IMasterStore(Specification)
+
+    def isDone(self):
+        """See `TunableLoop`."""
+        return self.rows_updated == 0
+
+    def __call__(self, chunk_size):
+        """See `TunableLoop`."""
+        subselect = Select(
+            Specification.id, Specification.information_type == None,
+            limit=chunk_size)
+        result = self.store.execute(
+            Update({Specification.information_type: 1},
+                   Specification.id.is_in(subselect)))
+        transaction.commit()
+        self.rows_updated = result.rowcount
+
+
 class UnusedPOTMsgSetPruner(TunableLoop):
     """Cleans up unused POTMsgSets."""
 
@@ -1395,6 +1430,7 @@
         OldTimeLimitedTokenDeleter,
         RevisionAuthorEmailLinker,
         ScrubPOFileTranslator,
+        SpecificationInformationTypeDefault,
         SuggestiveTemplatesCacheUpdater,
         POTranslationPruner,
         UnlinkedAccountPruner,

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2012-08-22 04:58:49 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2012-08-28 19:12:35 +0000
@@ -36,6 +36,7 @@
 from zope.security.proxy import removeSecurityProxy
 
 from lp.answers.model.answercontact import AnswerContact
+from lp.blueprints.model.specification import Specification
 from lp.bugs.model.bugnotification import (
     BugNotification,
     BugNotificationRecipient,
@@ -634,6 +635,18 @@
             "SELECT COUNT(*) FROM %s" % table_name).get_one()[0]
         self.failUnless(num_unexpired > 0)
 
+    def test_SpecificationInformationTypeDefault(self):
+        switch_dbuser('testadmin')
+        spec = self.factory.makeSpecification()
+        removeSecurityProxy(spec).information_type = None
+        store = Store.of(spec)
+        store.flush()
+        self.assertEqual(1, store.find(Specification,
+            Specification.information_type == None).count())
+        self.runDaily()
+        self.assertEqual(0, store.find(Specification,
+            Specification.information_type == None).count())
+
     def test_RevisionAuthorEmailLinker(self):
         switch_dbuser('testadmin')
         rev1 = self.factory.makeRevision('Author 1 <author-1@xxxxxxxxxxx>')


Follow ups