← Back to team overview

launchpad-reviewers team mailing list archive

lp:~adeuring/launchpad/filter-private-product-RosettaApplication into lp:launchpad

 

Abel Deuring has proposed merging lp:~adeuring/launchpad/filter-private-product-RosettaApplication into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~adeuring/launchpad/filter-private-product-RosettaApplication/+merge/131613

This branch changes the method TranslationsOverview.getMostTranslatedPillars() so that it does not return any private products.

It does not make much sense to include proprietary or embargoed products that the curent user can see. The method is used to show translatable products on the page https://translations.launchpad.net/ . Showing private products here might even concern some users  that their secret stuff might accidentally been shown publicly.

So I added just the expression 

  (product.information_type = InformationType.PUBLIC OR product.information_type IS NULL)

to the SQL query in getMostTranslatedPillars()

test: ./bin/test -vvt   lib/lp/translations/doc/translationsoverview.txt

no lint
-- 
https://code.launchpad.net/~adeuring/launchpad/filter-private-product-RosettaApplication/+merge/131613
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/launchpad/filter-private-product-RosettaApplication into lp:launchpad.
=== modified file 'lib/lp/translations/doc/translationsoverview.txt'
--- lib/lp/translations/doc/translationsoverview.txt	2012-01-20 15:42:44 +0000
+++ lib/lp/translations/doc/translationsoverview.txt	2012-10-26 13:17:35 +0000
@@ -177,6 +177,16 @@
     Evolution: 20
     Ubuntu: 24
 
+Private projects are never included.
+
+    >>> from lp.app.enums import InformationType
+    >>> removeSecurityProxy(upstart).information_type = (
+    ...     InformationType.PROPRIETARY)
+    >>> display_pillars(overview.getMostTranslatedPillars())
+    alsa-utils: 22
+    Evolution: 20
+    Ubuntu: 24
+
 
 Zero karma
 ----------

=== modified file 'lib/lp/translations/model/translationsoverview.py'
--- lib/lp/translations/model/translationsoverview.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/model/translationsoverview.py	2012-10-26 13:17:35 +0000
@@ -6,7 +6,10 @@
 
 from zope.interface import implements
 
-from lp.app.enums import ServiceUsage
+from lp.app.enums import (
+    InformationType,
+    ServiceUsage,
+    )
 from lp.registry.model.distribution import Distribution
 from lp.registry.model.product import Product
 from lp.services.database.sqlbase import (
@@ -68,16 +71,19 @@
                      distribution=distribution.id
               WHERE category=3 AND
                     (product IS NOT NULL OR distribution IS NOT NULL) AND
-                    (product.translations_usage = %s OR
-                        distribution.translations_usage = %s)
+                    (product.translations_usage = %s AND
+                     (product.information_type = %s OR
+                      product.information_type IS NULL) OR
+                    distribution.translations_usage = %s)
               GROUP BY product.displayname, product.id,
                        distribution.displayname, distribution.id
               HAVING SUM(karmavalue) > 0
               ORDER BY total_karma DESC
               LIMIT %s) AS something
           ORDER BY name""" % sqlvalues(ServiceUsage.LAUNCHPAD,
-                              ServiceUsage.LAUNCHPAD,
-                              limit)
+                                       InformationType.PUBLIC,
+                                       ServiceUsage.LAUNCHPAD,
+                                       limit)
         cur = cursor()
         cur.execute(query)
 


Follow ups