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

Proposed by Abel Deuring on 2012-10-26
Status: Merged
Approved by: Abel Deuring on 2012-10-26
Approved revision: no longer in the source branch.
Merged at revision: 16205
Proposed branch: lp:~adeuring/launchpad/filter-private-product-RosettaApplication
Merge into: lp:launchpad
Diff against target: 70 lines (+25/-5)
2 files modified
lib/lp/translations/doc/translationsoverview.txt (+10/-0)
lib/lp/translations/model/translationsoverview.py (+15/-5)
To merge this branch: bzr merge lp:~adeuring/launchpad/filter-private-product-RosettaApplication
Reviewer Review Type Date Requested Status
Deryck Hodge (community) 2012-10-26 Approve on 2012-10-26
Review via email: mp+131613@code.launchpad.net

Commit Message

omit private products in TranslationsOverview.getMostTranslatedPillars()

Description of the Change

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

To post a comment you must log in.
Deryck Hodge (deryck) wrote :

Looks good, generally. As mentioned here in person, we need an XXX to note that we don't want this check for NULL once Product.information_type cannot be NULL. Once the XXX is in place, landing this sounds fine. Also, please add a card to the Kanban board reminding us to revisit this code.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/doc/translationsoverview.txt'
2--- lib/lp/translations/doc/translationsoverview.txt 2012-01-20 15:42:44 +0000
3+++ lib/lp/translations/doc/translationsoverview.txt 2012-10-26 13:34:23 +0000
4@@ -177,6 +177,16 @@
5 Evolution: 20
6 Ubuntu: 24
7
8+Private projects are never included.
9+
10+ >>> from lp.app.enums import InformationType
11+ >>> removeSecurityProxy(upstart).information_type = (
12+ ... InformationType.PROPRIETARY)
13+ >>> display_pillars(overview.getMostTranslatedPillars())
14+ alsa-utils: 22
15+ Evolution: 20
16+ Ubuntu: 24
17+
18
19 Zero karma
20 ----------
21
22=== modified file 'lib/lp/translations/model/translationsoverview.py'
23--- lib/lp/translations/model/translationsoverview.py 2011-12-30 06:14:56 +0000
24+++ lib/lp/translations/model/translationsoverview.py 2012-10-26 13:34:23 +0000
25@@ -6,7 +6,10 @@
26
27 from zope.interface import implements
28
29-from lp.app.enums import ServiceUsage
30+from lp.app.enums import (
31+ InformationType,
32+ ServiceUsage,
33+ )
34 from lp.registry.model.distribution import Distribution
35 from lp.registry.model.product import Product
36 from lp.services.database.sqlbase import (
37@@ -49,6 +52,10 @@
38 def getMostTranslatedPillars(self, limit=50):
39 """See `ITranslationsOverview`."""
40
41+ # XXX Abel Deuring 2012-10-26 bug=1071751
42+ # The expression product.information_type IS NULL can be
43+ # removed once we have the DB constraint
44+ # "Product.information_type IS NULL".
45 query = """
46 SELECT LOWER(COALESCE(product_name, distro_name)) AS name,
47 product_id,
48@@ -68,16 +75,19 @@
49 distribution=distribution.id
50 WHERE category=3 AND
51 (product IS NOT NULL OR distribution IS NOT NULL) AND
52- (product.translations_usage = %s OR
53- distribution.translations_usage = %s)
54+ (product.translations_usage = %s AND
55+ (product.information_type = %s OR
56+ product.information_type IS NULL) OR
57+ distribution.translations_usage = %s)
58 GROUP BY product.displayname, product.id,
59 distribution.displayname, distribution.id
60 HAVING SUM(karmavalue) > 0
61 ORDER BY total_karma DESC
62 LIMIT %s) AS something
63 ORDER BY name""" % sqlvalues(ServiceUsage.LAUNCHPAD,
64- ServiceUsage.LAUNCHPAD,
65- limit)
66+ InformationType.PUBLIC,
67+ ServiceUsage.LAUNCHPAD,
68+ limit)
69 cur = cursor()
70 cur.execute(query)
71