← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rharding/launchpad/move_into_utils into lp:launchpad

 

Richard Harding has proposed merging lp:~rharding/launchpad/move_into_utils into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1051954 in Launchpad itself: "json_dump_information_types does not belong in enums.py"
  https://bugs.launchpad.net/launchpad/+bug/1051954

For more details, see:
https://code.launchpad.net/~rharding/launchpad/move_into_utils/+merge/124678

= Summary =

This json_dump_information_types method doesn't belong in enums.py and should
be moved.


== Pre Implementation ==

Talked with JC during original code review and StevenK on locations to move it
to.


== Implementation Notes ==

Moves the method to a new registry/utils.py and updated the usage to import
from the new location.

-- 
https://code.launchpad.net/~rharding/launchpad/move_into_utils/+merge/124678
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/move_into_utils into lp:launchpad.
=== modified file 'lib/lp/app/browser/informationtype.py'
--- lib/lp/app/browser/informationtype.py	2012-09-14 00:59:44 +0000
+++ lib/lp/app/browser/informationtype.py	2012-09-17 13:24:19 +0000
@@ -8,10 +8,8 @@
 
 from lazr.restful.interfaces import IJSONRequestCache
 
-from lp.registry.enums import (
-    json_dump_information_types,
-    PRIVATE_INFORMATION_TYPES
-    )
+from lp.registry.enums import PRIVATE_INFORMATION_TYPES
+from lp.registry.utils import json_dump_information_types
 
 
 class InformationTypePortletMixin:

=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py	2012-09-14 00:59:44 +0000
+++ lib/lp/bugs/browser/bugtarget.py	2012-09-17 13:24:19 +0000
@@ -116,7 +116,6 @@
     ProductPrivateBugsMixin,
     )
 from lp.registry.enums import (
-    json_dump_information_types,
     InformationType,
     PRIVATE_INFORMATION_TYPES,
     PUBLIC_INFORMATION_TYPES,
@@ -136,6 +135,7 @@
     InformationTypeVocabulary,
     ValidPersonOrTeamVocabulary,
     )
+from lp.registry.utils import json_dump_information_types
 from lp.services.config import config
 from lp.services.job.interfaces.job import JobStatus
 from lp.services.librarian.browser import ProxiedLibraryFileAlias

=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py	2012-09-14 00:59:44 +0000
+++ lib/lp/registry/browser/product.py	2012-09-17 13:24:19 +0000
@@ -158,10 +158,7 @@
     PillarViewMixin,
     )
 from lp.registry.browser.productseries import get_series_branch_error
-from lp.registry.enums import (
-    json_dump_information_types,
-    InformationType,
-    )
+from lp.registry.enums import InformationType
 from lp.registry.interfaces.pillar import IPillarNameSet
 from lp.registry.interfaces.product import (
     IProduct,
@@ -177,6 +174,7 @@
 from lp.registry.interfaces.productseries import IProductSeries
 from lp.registry.interfaces.series import SeriesStatus
 from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
+from lp.registry.utils import json_dump_information_types
 from lp.services.config import config
 from lp.services.database.decoratedresultset import DecoratedResultSet
 from lp.services.feeds.browser import FeedsMixin

=== modified file 'lib/lp/registry/enums.py'
--- lib/lp/registry/enums.py	2012-09-16 12:49:11 +0000
+++ lib/lp/registry/enums.py	2012-09-17 13:24:19 +0000
@@ -110,21 +110,6 @@
 )
 
 
-def json_dump_information_types(cache, information_types):
-    """Dump a dict of the data in the types requested."""
-    dump = {}
-    order = list(InformationType.sort_order)
-    for term in information_types:
-        dump[term.name] = {
-            'value': term.name,
-            'description': term.description,
-            'name': term.title,
-            'order': order.index(term.name),
-            'is_private': (term not in PUBLIC_INFORMATION_TYPES), 'description_css_class': 'choice-description',
-        }
-
-    cache.objects['information_type_data'] = dump
-
 class SharingPermission(DBEnumeratedType):
     """Sharing permission.
 

=== added file 'lib/lp/registry/utils.py'
--- lib/lp/registry/utils.py	1970-01-01 00:00:00 +0000
+++ lib/lp/registry/utils.py	2012-09-17 13:24:19 +0000
@@ -0,0 +1,23 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+from lp.registry.enums import (
+    InformationType,
+    PRIVATE_INFORMATION_TYPES,
+    )
+
+
+def json_dump_information_types(cache, information_types):
+    """Dump a dict of the data in the types requested."""
+    dump = {}
+    order = list(InformationType.sort_order)
+    for term in information_types:
+        dump[term.name] = {
+            'value': term.name,
+            'description': term.description,
+            'name': term.title,
+            'order': order.index(term.name),
+            'is_private': (term in PRIVATE_INFORMATION_TYPES),
+            'description_css_class': 'choice-description',
+        }
+
+    cache.objects['information_type_data'] = dump


Follow ups