Merge lp:~adeuring/launchpad/bug-596944-model into lp:launchpad/db-devel

Proposed by Abel Deuring
Status: Merged
Approved by: Leonard Richardson
Approved revision: no longer in the source branch.
Merged at revision: 10022
Proposed branch: lp:~adeuring/launchpad/bug-596944-model
Merge into: lp:launchpad/db-devel
Diff against target: 314 lines (+191/-3)
9 files modified
lib/lp/bugs/interfaces/bugtarget.py (+4/-0)
lib/lp/bugs/model/bugtarget.py (+4/-0)
lib/lp/bugs/tests/test_bugtarget2.py (+156/-0)
lib/lp/registry/configure.zcml (+5/-1)
lib/lp/registry/interfaces/projectgroup.py (+4/-0)
lib/lp/registry/model/distributionsourcepackage.py (+6/-2)
lib/lp/registry/model/product.py (+1/-0)
lib/lp/registry/model/productseries.py (+5/-0)
lib/lp/registry/model/sourcepackage.py (+6/-0)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-596944-model
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+42253@code.launchpad.net

Commit message

[incr] [r=leonardr][ui=none][bug=596944] property enable_bugfiling_duplicate_search added to bug target model classes.

Description of the change

This branch is a step to fix bug 596944: Allow projects to
disable duplicate detection when reporting a bug. It adds a
new property enable_bugfiling_duplicate_search to bug target
classes and to ProjectGroup.

The option to enable or disable dupe search will be selectable
only for products and for source packages (see also this
branch: lp:~adeuring/launchpad/bug-596944-schema); I added the
property to all bug targets so that we don't need to check in
browser code if the current bug target has the property
enable_bugfiling_duplicate_search.

So we have three cases:
- enable_bugfiling_duplicate_search is always True: This is the
  case for distributions and for project groups
- enable_bugfiling_duplicate_search is settable: products and
  DSPs
- enable_bugfiling_duplicate_search is inherited from a parent
  object: product series and source package.

test: ./bin/test -vvt test_bugtarget2

no lint

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
--- lib/lp/bugs/interfaces/bugtarget.py 2010-11-18 14:00:49 +0000
+++ lib/lp/bugs/interfaces/bugtarget.py 2010-11-30 15:18:35 +0000
@@ -297,6 +297,10 @@
297 required=False,297 required=False,
298 max_length=50000))298 max_length=50000))
299299
300 enable_bugfiling_duplicate_search = Bool(
301 title=u"Search for possible duplicate bugs when a new bug is filed",
302 required=False)
303
300 def createBug(bug_params):304 def createBug(bug_params):
301 """Create a new bug on this target.305 """Create a new bug on this target.
302306
303307
=== modified file 'lib/lp/bugs/model/bugtarget.py'
--- lib/lp/bugs/model/bugtarget.py 2010-11-18 14:00:49 +0000
+++ lib/lp/bugs/model/bugtarget.py 2010-11-30 15:18:35 +0000
@@ -244,6 +244,10 @@
244 All IBugTargets should inherit from this class.244 All IBugTargets should inherit from this class.
245 """245 """
246246
247 # The default implementation of the property, used for
248 # IDistribution, IDistroSeries, IProjectGroup.
249 enable_bugfiling_duplicate_search = True
250
247251
248class HasBugHeatMixin:252class HasBugHeatMixin:
249 """Standard functionality for objects implementing IHasBugHeat."""253 """Standard functionality for objects implementing IHasBugHeat."""
250254
=== added file 'lib/lp/bugs/tests/test_bugtarget2.py'
--- lib/lp/bugs/tests/test_bugtarget2.py 1970-01-01 00:00:00 +0000
+++ lib/lp/bugs/tests/test_bugtarget2.py 2010-11-30 15:18:35 +0000
@@ -0,0 +1,156 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Tests for BugTargets."""
5
6__metaclass__ = type
7
8from zope.security.interfaces import ForbiddenAttribute
9
10from canonical.testing.layers import DatabaseFunctionalLayer
11from lp.testing import (
12 person_logged_in,
13 TestCaseWithFactory,
14 )
15
16
17class BugTargetBugFilingDuplicateSearchAlwaysOn:
18 """A base class for tests of bug targets where dupes are always searched.
19 """
20
21 def test_enable_bugfiling_duplicate_search(self):
22 # enable_bugfiling_duplicate_search is always True.
23 self.assertTrue(self.bugtarget.enable_bugfiling_duplicate_search)
24
25 def test_enable_bugfiling_duplicate_search_is_read_only(self):
26 # enable_bugfiling_duplicate_search is a read-only attribute
27 with person_logged_in(self.bugtarget.owner):
28 self.assertRaises(
29 ForbiddenAttribute, setattr, self.bugtarget,
30 'enable_bugfiling_duplicate_search', False)
31
32
33class TestDistribution(BugTargetBugFilingDuplicateSearchAlwaysOn,
34 TestCaseWithFactory):
35 """Tests for distributions as bug targets."""
36
37 layer = DatabaseFunctionalLayer
38
39 def setUp(self):
40 super(TestDistribution, self).setUp()
41 self.bugtarget = self.factory.makeDistribution()
42
43
44class TestDistroSeries(BugTargetBugFilingDuplicateSearchAlwaysOn,
45 TestCaseWithFactory):
46 """Tests for distributions as bug targets."""
47
48 layer = DatabaseFunctionalLayer
49
50 def setUp(self):
51 super(TestDistroSeries, self).setUp()
52 self.bugtarget = self.factory.makeDistroSeries()
53
54
55class TestProjectGroup(BugTargetBugFilingDuplicateSearchAlwaysOn,
56 TestCaseWithFactory):
57 """Tests for distributions as bug targets."""
58
59 layer = DatabaseFunctionalLayer
60
61 def setUp(self):
62 super(TestProjectGroup, self).setUp()
63 self.bugtarget = self.factory.makeProject()
64
65
66class BugTargetBugFilingDuplicateSearchSettable:
67 """A base class for tests of bug targets where dupe search is settable.
68 """
69
70 def test_enable_bugfiling_duplicate_search_default(self):
71 # The default value of enable_bugfiling_duplicate_search is True.
72 self.assertTrue(self.bugtarget.enable_bugfiling_duplicate_search)
73
74 def test_enable_bugfiling_duplicate_search_is_changeable(self):
75 # The bug supervisor can change enable_bugfiling_duplicate_search.
76 with person_logged_in(self.bug_supervisor):
77 self.bugtarget.enable_bugfiling_duplicate_search = False
78 self.assertFalse(self.bugtarget.enable_bugfiling_duplicate_search)
79
80
81class TestProduct(BugTargetBugFilingDuplicateSearchSettable,
82 TestCaseWithFactory):
83 """Tests for products as bug targets."""
84
85 layer = DatabaseFunctionalLayer
86
87 def setUp(self):
88 super(TestProduct, self).setUp()
89 self.bug_supervisor = self.factory.makePerson()
90 self.bugtarget = self.factory.makeProduct(
91 bug_supervisor=self.bug_supervisor)
92
93
94class TestDistributionSourcePackage(BugTargetBugFilingDuplicateSearchSettable,
95 TestCaseWithFactory):
96 """Tests for distributionsourcepackages as bug targets."""
97
98 layer = DatabaseFunctionalLayer
99
100 def setUp(self):
101 super(TestDistributionSourcePackage, self).setUp()
102 self.bug_supervisor = self.factory.makePerson()
103 distribution = self.factory.makeDistribution(
104 bug_supervisor=self.bug_supervisor)
105 self.bugtarget = self.factory.makeDistributionSourcePackage(
106 distribution=distribution)
107
108
109class BugTargetBugFilingDuplicateSearchInherited:
110 """A base class for tests of bug targets where the dupe search policy
111 is inherited from a parent object.
112 """
113
114 def test_enable_bugfiling_duplicate_search_default(self):
115 # The default value of enable_bugfiling_duplicate_search is True.
116 self.assertTrue(self.bugtarget.enable_bugfiling_duplicate_search)
117
118 def test_enable_bugfiling_duplicate_search_changed_by_parent_change(self):
119 # If enable_bugfiling_duplicate_search is changed for the parent
120 # object, it is changed for the bug traget too.
121 with person_logged_in(self.bug_supervisor):
122 self.bugtarget_parent.enable_bugfiling_duplicate_search = False
123 self.assertFalse(self.bugtarget.enable_bugfiling_duplicate_search)
124
125
126class TestProductSeries(BugTargetBugFilingDuplicateSearchInherited,
127 TestCaseWithFactory):
128 """Tests for product serieses as bug targets."""
129
130 layer = DatabaseFunctionalLayer
131
132 def setUp(self):
133 super(TestProductSeries, self).setUp()
134 self.bug_supervisor = self.factory.makePerson()
135 self.bugtarget_parent = self.factory.makeProduct(
136 bug_supervisor=self.bug_supervisor)
137 self.bugtarget = self.factory.makeProductSeries(
138 product=self.bugtarget_parent)
139
140
141class TestSourcePackage(BugTargetBugFilingDuplicateSearchInherited,
142 TestCaseWithFactory):
143 """Tests for product serieses as bug targets."""
144
145 layer = DatabaseFunctionalLayer
146
147 def setUp(self):
148 super(TestSourcePackage, self).setUp()
149 self.bug_supervisor = self.factory.makePerson()
150 distribution = self.factory.makeDistribution(
151 bug_supervisor=self.bug_supervisor)
152 distroseries = self.factory.makeDistroSeries(
153 distribution=distribution)
154 self.bugtarget = self.factory.makeSourcePackage(
155 distroseries=distroseries)
156 self.bugtarget_parent = self.bugtarget.distribution_sourcepackage
0157
=== modified file 'lib/lp/registry/configure.zcml'
--- lib/lp/registry/configure.zcml 2010-11-27 05:40:38 +0000
+++ lib/lp/registry/configure.zcml 2010-11-30 15:18:35 +0000
@@ -449,6 +449,7 @@
449 displayname449 displayname
450 distribution450 distribution
451 distro451 distro
452 enable_bugfiling_duplicate_search
452 findRelatedArchivePublications453 findRelatedArchivePublications
453 findRelatedArchives454 findRelatedArchives
454 getBugCounts455 getBugCounts
@@ -512,7 +513,9 @@
512 permission="launchpad.BugSupervisor"513 permission="launchpad.BugSupervisor"
513 set_attributes="514 set_attributes="
514 bug_reported_acknowledgement515 bug_reported_acknowledgement
515 bug_reporting_guidelines"/>516 bug_reporting_guidelines
517 enable_bugfiling_duplicate_search
518 "/>
516 </class>519 </class>
517 <adapter520 <adapter
518 for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"521 for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"
@@ -1179,6 +1182,7 @@
1179 <require1182 <require
1180 permission="launchpad.BugSupervisor"1183 permission="launchpad.BugSupervisor"
1181 set_attributes="1184 set_attributes="
1185 enable_bugfiling_duplicate_search
1182 bug_reported_acknowledgement1186 bug_reported_acknowledgement
1183 bug_reporting_guidelines1187 bug_reporting_guidelines
1184 bugtracker1188 bugtracker
11851189
=== modified file 'lib/lp/registry/interfaces/projectgroup.py'
--- lib/lp/registry/interfaces/projectgroup.py 2010-11-05 09:59:37 +0000
+++ lib/lp/registry/interfaces/projectgroup.py 2010-11-30 15:18:35 +0000
@@ -311,6 +311,10 @@
311 required=False,311 required=False,
312 max_length=50000))312 max_length=50000))
313313
314 enable_bugfiling_duplicate_search = Bool(
315 title=u"Search for possible duplicate bugs when a new bug is filed",
316 required=False, readonly=True)
317
314 def getProduct(name):318 def getProduct(name):
315 """Get a product with name `name`."""319 """Get a product with name `name`."""
316320
317321
=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
--- lib/lp/registry/model/distributionsourcepackage.py 2010-11-05 09:16:14 +0000
+++ lib/lp/registry/model/distributionsourcepackage.py 2010-11-30 15:18:35 +0000
@@ -101,11 +101,12 @@
101101
102class DistributionSourcePackageProperty:102class DistributionSourcePackageProperty:
103103
104 def __init__(self, attrname):104 def __init__(self, attrname, default=None):
105 self.attrname = attrname105 self.attrname = attrname
106 self.default = default
106107
107 def __get__(self, obj, class_):108 def __get__(self, obj, class_):
108 return getattr(obj._self_in_database, self.attrname, None)109 return getattr(obj._self_in_database, self.attrname, self.default)
109110
110 def __set__(self, obj, value):111 def __set__(self, obj, value):
111 if obj._self_in_database is None:112 if obj._self_in_database is None:
@@ -152,6 +153,8 @@
152 po_message_count = DistributionSourcePackageProperty('po_message_count')153 po_message_count = DistributionSourcePackageProperty('po_message_count')
153 is_upstream_link_allowed = DistributionSourcePackageProperty(154 is_upstream_link_allowed = DistributionSourcePackageProperty(
154 'is_upstream_link_allowed')155 'is_upstream_link_allowed')
156 enable_bugfiling_duplicate_search = DistributionSourcePackageProperty(
157 'enable_bugfiling_duplicate_search', default=True)
155158
156 def __init__(self, distribution, sourcepackagename):159 def __init__(self, distribution, sourcepackagename):
157 self.distribution = distribution160 self.distribution = distribution
@@ -607,3 +610,4 @@
607 bug_count = Int()610 bug_count = Int()
608 po_message_count = Int()611 po_message_count = Int()
609 is_upstream_link_allowed = Bool()612 is_upstream_link_allowed = Bool()
613 enable_bugfiling_duplicate_search = Bool()
610614
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2010-11-27 05:40:38 +0000
+++ lib/lp/registry/model/product.py 2010-11-30 15:18:35 +0000
@@ -453,6 +453,7 @@
453 default=None)453 default=None)
454 bug_reporting_guidelines = StringCol(default=None)454 bug_reporting_guidelines = StringCol(default=None)
455 bug_reported_acknowledgement = StringCol(default=None)455 bug_reported_acknowledgement = StringCol(default=None)
456 enable_bugfiling_duplicate_search = BoolCol(notNull=True, default=True)
456 _cached_licenses = None457 _cached_licenses = None
457458
458 def _validate_active(self, attr, value):459 def _validate_active(self, attr, value):
459460
=== modified file 'lib/lp/registry/model/productseries.py'
--- lib/lp/registry/model/productseries.py 2010-11-27 05:40:38 +0000
+++ lib/lp/registry/model/productseries.py 2010-11-30 15:18:35 +0000
@@ -270,6 +270,11 @@
270 return self.product.bug_reported_acknowledgement270 return self.product.bug_reported_acknowledgement
271271
272 @property272 @property
273 def enable_bugfiling_duplicate_search(self):
274 """See `IBugTarget`."""
275 return self.product.enable_bugfiling_duplicate_search
276
277 @property
273 def sourcepackages(self):278 def sourcepackages(self):
274 """See IProductSeries"""279 """See IProductSeries"""
275 from lp.registry.model.sourcepackage import SourcePackage280 from lp.registry.model.sourcepackage import SourcePackage
276281
=== modified file 'lib/lp/registry/model/sourcepackage.py'
--- lib/lp/registry/model/sourcepackage.py 2010-11-15 16:25:05 +0000
+++ lib/lp/registry/model/sourcepackage.py 2010-11-30 15:18:35 +0000
@@ -476,6 +476,12 @@
476 """See `IBugTarget`."""476 """See `IBugTarget`."""
477 return self.distribution.bug_reported_acknowledgement477 return self.distribution.bug_reported_acknowledgement
478478
479 @property
480 def enable_bugfiling_duplicate_search(self):
481 """See `IBugTarget`."""
482 return (
483 self.distribution_sourcepackage.enable_bugfiling_duplicate_search)
484
479 def _customizeSearchParams(self, search_params):485 def _customizeSearchParams(self, search_params):
480 """Customize `search_params` for this source package."""486 """Customize `search_params` for this source package."""
481 search_params.setSourcePackage(self)487 search_params.setSourcePackage(self)

Subscribers

People subscribed via source and target branches

to status/vote changes: