launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15536
[Merge] lp:~stevenk/launchpad/bugtracker-index-filter-hidden-projects into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/bugtracker-index-filter-hidden-projects into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1174542 in Launchpad itself: "Bug tracker linked to private project causes BugTrackerSet:+index to 403"
https://bugs.launchpad.net/launchpad/+bug/1174542
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/bugtracker-index-filter-hidden-projects/+merge/162157
While QAing the previous change for this bug, namely BugTrackerSet:+index and private projects, I noticed that BugTracker:+index suffers from the same problem.
--
https://code.launchpad.net/~stevenk/launchpad/bugtracker-index-filter-hidden-projects/+merge/162157
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/bugtracker-index-filter-hidden-projects into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtracker.py'
--- lib/lp/bugs/browser/bugtracker.py 2013-05-01 18:49:40 +0000
+++ lib/lp/bugs/browser/bugtracker.py 2013-05-02 16:32:42 +0000
@@ -21,8 +21,6 @@
'RemoteBug',
]
-from itertools import chain
-
from lazr.restful.utils import smartquote
from zope.component import getUtility
from zope.formlib import form
@@ -227,7 +225,7 @@
This property was created for the Related projects portlet in
the bug tracker's page.
"""
- pillars = chain(self.context.projects, self.context.products)
+ pillars = self.context.getRelatedPillars(self.user)
return shortlist([p for p in pillars if p.active], 100)
@property
=== modified file 'lib/lp/bugs/browser/tests/test_bugtracker_views.py'
--- lib/lp/bugs/browser/tests/test_bugtracker_views.py 2013-05-01 18:49:40 +0000
+++ lib/lp/bugs/browser/tests/test_bugtracker_views.py 2013-05-02 16:32:42 +0000
@@ -46,6 +46,15 @@
view = create_initialized_view(tracker, name='+index')
self.assertEqual([active_product], view.related_projects)
+ def test_bugtracker_with_private_project(self):
+ tracker = self.factory.makeBugTracker()
+ product = self.factory.makeProduct(
+ information_type=InformationType.PROPRIETARY, name='foobar')
+ with admin_logged_in():
+ product.bugtracker = tracker
+ view = create_initialized_view(tracker, name='+index')
+ self.assertEqual([], view.related_projects)
+
class TestBugTrackerSetView(TestCaseWithFactory):
=== modified file 'lib/lp/bugs/configure.zcml'
--- lib/lp/bugs/configure.zcml 2013-04-11 05:32:33 +0000
+++ lib/lp/bugs/configure.zcml 2013-05-02 16:32:42 +0000
@@ -382,14 +382,13 @@
multi_product
name
owner
- products
- projects
summary
title
watches
watches_needing_update
watches_ready_to_check
watches_with_unpushed_comments
+ getRelatedPillars
"/>
<require
permission="launchpad.Edit"
=== modified file 'lib/lp/bugs/interfaces/bugtracker.py'
--- lib/lp/bugs/interfaces/bugtracker.py 2013-05-01 18:49:40 +0000
+++ lib/lp/bugs/interfaces/bugtracker.py 2013-05-02 16:32:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Bug tracker interfaces."""
@@ -287,8 +287,6 @@
Bool(
title=_('This bug tracker has a Launchpad plugin installed.'),
required=False, default=False))
- projects = Attribute('The projects that use this bug tracker.')
- products = Attribute('The products that use this bug tracker.')
latestwatches = Attribute('The last 10 watches created.')
imported_bug_messages = Attribute(
'Bug messages that have been imported from this bug tracker.')
@@ -419,6 +417,10 @@
If no components have been linked, returns value of None.
"""
+ def getRelatedPillars(user=None):
+ """Returns the `IProduct`s and `IProjectGroup`s that use this tracker.
+ """
+
class IBugTrackerSet(Interface):
"""A set of IBugTracker's.
=== modified file 'lib/lp/bugs/model/bugtracker.py'
--- lib/lp/bugs/model/bugtracker.py 2013-05-01 21:40:25 +0000
+++ lib/lp/bugs/model/bugtracker.py 2013-05-02 16:32:42 +0000
@@ -307,8 +307,8 @@
_table = 'BugTracker'
- bugtrackertype = EnumCol(dbName='bugtrackertype',
- schema=BugTrackerType, notNull=True)
+ bugtrackertype = EnumCol(
+ dbName='bugtrackertype', schema=BugTrackerType, notNull=True)
name = StringCol(notNull=True, unique=True)
title = StringCol(notNull=True)
summary = StringCol(notNull=False)
@@ -321,10 +321,6 @@
storm_validator=validate_public_person, notNull=True)
contactdetails = StringCol(notNull=False)
has_lp_plugin = BoolCol(notNull=False, default=False)
- projects = SQLMultipleJoin(
- 'ProjectGroup', joinColumn='bugtracker', orderBy='name')
- products = SQLMultipleJoin(
- 'Product', joinColumn='bugtracker', orderBy='name')
watches = SQLMultipleJoin(
'BugWatch', joinColumn='bugtracker', orderBy='-datecreated',
prejoins=['bug'])
@@ -715,6 +711,18 @@
BugTrackerComponent.source_package_name ==
dsp.sourcepackagename.id).one()
+ def getRelatedPillars(self, user=None):
+ """See `IBugTracker`."""
+ products = IStore(Product).find(
+ Product,
+ Product.bugtrackerID == self.id, Product.active == True,
+ ProductSet.getProductPrivacyFilter(user)).order_by(Product.name)
+ groups = IStore(ProjectGroup).find(
+ ProjectGroup,
+ ProjectGroup.bugtrackerID == self.id,
+ ProjectGroup.active == True).order_by(ProjectGroup.name)
+ return list(groups) + list(products)
+
class BugTrackerSet:
"""Implements IBugTrackerSet for a container or set of BugTrackers,