Merge lp:~stevenk/launchpad/illegaltarget-if-pillar-is-new into lp:launchpad

Proposed by Steve Kowalik on 2012-09-11
Status: Merged
Approved by: William Grant on 2012-09-12
Approved revision: no longer in the source branch.
Merged at revision: 15941
Proposed branch: lp:~stevenk/launchpad/illegaltarget-if-pillar-is-new
Merge into: lp:launchpad
Diff against target: 35 lines (+14/-1)
2 files modified
lib/lp/bugs/model/bugtask.py (+2/-1)
lib/lp/bugs/model/tests/test_bugtask.py (+12/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/illegaltarget-if-pillar-is-new
Reviewer Review Type Date Requested Status
William Grant code 2012-09-11 Approve on 2012-09-12
Review via email: mp+123862@code.launchpad.net

Commit Message

Only validate if the information_type of a bug is legal if it's targeting a new pillar. This allows users to nominate bugs against series if the bug is already bending the rules.

Description of the Change

Only validate if the information_type of a bug is legal if it's targeting a new pillar. This allows users to nominate bugs against series if the bug is already bending the rules.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bugtask.py'
2--- lib/lp/bugs/model/bugtask.py 2012-08-30 12:22:35 +0000
3+++ lib/lp/bugs/model/bugtask.py 2012-09-12 00:58:18 +0000
4@@ -338,7 +338,8 @@
5 raise IllegalTarget(e[0])
6
7 legal_types = target.pillar.getAllowedBugInformationTypes()
8- if bug.information_type not in legal_types:
9+ new_pillar = target.pillar not in bug.affected_pillars
10+ if new_pillar and bug.information_type not in legal_types:
11 raise IllegalTarget(
12 "%s doesn't allow %s bugs." % (
13 target.pillar.bugtargetdisplayname, bug.information_type.title))
14
15=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
16--- lib/lp/bugs/model/tests/test_bugtask.py 2012-08-30 12:22:35 +0000
17+++ lib/lp/bugs/model/tests/test_bugtask.py 2012-09-12 00:58:18 +0000
18@@ -3055,6 +3055,18 @@
19 "%s doesn't allow Public bugs." % commercial_prod.displayname,
20 validate_target, bug, commercial_prod)
21
22+ def test_illegal_information_type_allowed_if_pillar_not_new(self):
23+ # The bug's current information_type does not have to be permitted if
24+ # we already affect the pillar.
25+ prod = self.factory.makeProduct()
26+ series = self.factory.makeProductSeries(product=prod)
27+ bug = self.factory.makeBug(
28+ target=prod, information_type=InformationType.USERDATA)
29+ self.factory.makeCommercialSubscription(prod)
30+ with person_logged_in(prod.owner):
31+ prod.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY)
32+ validate_target(bug, series)
33+
34
35 class TestValidateNewTarget(TestCaseWithFactory, ValidateTargetMixin):
36