12337.2.8
by Jeroen Vermeulen
Query more specifically for branches with visible bugs attached, to save time on unneeded work. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.15
by Karl Fogel
Add the copyright header block to files under lib/lp/bugs/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
4983.1.1
by Curtis Hovey
Added lint exceptions to __init__.py and interface/*.py. |
4 |
# pylint: disable-msg=E0211,E0213
|
3283.3.1
by Brad Bollenbach
create a new branch for bzr integration, to avoid 3 hour merge time |
5 |
|
6 |
"""Interfaces for linking BugTasks and Branches."""
|
|
7 |
||
8 |
__metaclass__ = type |
|
9 |
||
4789.4.6
by Tim Penhey
Moving the DBSchema and adding pagetests. |
10 |
__all__ = [ |
11 |
"IBugBranch", |
|
12 |
"IBugBranchSet", |
|
13 |
]
|
|
3283.3.1
by Brad Bollenbach
create a new branch for bzr integration, to avoid 3 hour merge time |
14 |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
15 |
from lazr.restful.declarations import ( |
16 |
export_as_webservice_entry, |
|
17 |
exported, |
|
18 |
)
|
|
19 |
from lazr.restful.fields import ReferenceChoice |
|
3283.3.1
by Brad Bollenbach
create a new branch for bzr integration, to avoid 3 hour merge time |
20 |
from zope.interface import Interface |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
21 |
from zope.schema import ( |
22 |
Int, |
|
23 |
Object, |
|
24 |
TextLine, |
|
25 |
)
|
|
3283.3.1
by Brad Bollenbach
create a new branch for bzr integration, to avoid 3 hour merge time |
26 |
|
14600.1.12
by Curtis Hovey
Move i18n to lp. |
27 |
from lp import _ |
14560.2.25
by Curtis Hovey
Merged c.l.interfaces.launchpad with lp.app.interfaces.launchpad. |
28 |
from lp.app.interfaces.launchpad import IHasDateCreated |
14560.2.23
by Curtis Hovey
Moved IHasBug to its own module. |
29 |
from lp.bugs.interfaces.hasbug import IHasBug |
8523.3.1
by Gavin Panella
Bugs tree reorg after automated migration. |
30 |
from lp.bugs.interfaces.bugtask import IBugTask |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
31 |
from lp.code.interfaces.branch import IBranch |
8339.2.14
by Paul Hummer
Fixed the oops (man, that was easier than I expected |
32 |
from lp.code.interfaces.branchtarget import IHasBranchTarget |
7675.110.3
by Curtis Hovey
Ran the migration script to move registry code to lp.registry. |
33 |
from lp.registry.interfaces.person import IPerson |
14550.1.1
by Steve Kowalik
Run format-imports over lib/lp and lib/canonical/launchpad |
34 |
from lp.services.fields import BugField |
4911.3.1
by Tom Berger
merge changes from rocketfuel and resolve conflicts |
35 |
|
4789.4.6
by Tim Penhey
Moving the DBSchema and adding pagetests. |
36 |
|
8339.2.14
by Paul Hummer
Fixed the oops (man, that was easier than I expected |
37 |
class IBugBranch(IHasDateCreated, IHasBug, IHasBranchTarget): |
3283.3.3
by Brad Bollenbach
pair code reviewing with lifeless |
38 |
"""A branch linked to a bug."""
|
39 |
||
8302.2.5
by Paul Hummer
Exported IBugBranch |
40 |
export_as_webservice_entry() |
41 |
||
3283.3.1
by Brad Bollenbach
create a new branch for bzr integration, to avoid 3 hour merge time |
42 |
id = Int(title=_("Bug Branch #")) |
8302.2.13
by Paul Hummer
Fixed broken tests |
43 |
bug = exported( |
44 |
BugField( |
|
9084.1.10
by Tim Penhey
Updates following review. |
45 |
title=_("Bug #"), |
8302.2.13
by Paul Hummer
Fixed broken tests |
46 |
required=True, readonly=True)) |
12337.2.2
by Jeroen Vermeulen
Expose BugBranch.branch_id. |
47 |
branch_id = Int(title=_("Branch ID"), required=True, readonly=True) |
8302.2.5
by Paul Hummer
Exported IBugBranch |
48 |
branch = exported( |
8302.2.13
by Paul Hummer
Fixed broken tests |
49 |
ReferenceChoice( |
8302.2.5
by Paul Hummer
Exported IBugBranch |
50 |
title=_("Branch"), schema=IBranch, |
8302.2.13
by Paul Hummer
Fixed broken tests |
51 |
vocabulary="Branch", required=True)) |
3836.3.2
by jml at canonical
Merge in only the RevisionProperty-related changes from auto-bug-branch. |
52 |
revision_hint = TextLine(title=_("Revision Hint")) |
3755.4.1
by Tim Penhey
Basics working for IBugBranchSet |
53 |
|
4789.4.8
by Tim Penhey
Removed old status view, made inline edits of bug branch links. |
54 |
bug_task = Object( |
55 |
schema=IBugTask, title=_("The bug task that the branch fixes"), |
|
56 |
description=_( |
|
57 |
"the bug task reported against this branch's product or the "
|
|
58 |
"first bug task (in case where there is no task reported "
|
|
59 |
"against the branch's product)."), |
|
60 |
readonly=True) |
|
61 |
||
5001.1.4
by Tim Penhey
Added registrants to BugBranch and SpecificationBranch. |
62 |
registrant = Object( |
63 |
schema=IPerson, readonly=True, required=True, |
|
64 |
title=_("The person who linked the bug to the branch")) |
|
65 |
||
4776.3.6
by Tim Penhey
Text only changes following review. |
66 |
|
3755.4.1
by Tim Penhey
Basics working for IBugBranchSet |
67 |
class IBugBranchSet(Interface): |
68 |
||
5291.2.5
by jml at canonical
Improve factoring slightly by providing a method to get a BugBranch by bug |
69 |
def getBugBranch(bug, branch): |
70 |
"""Return the BugBranch for the given bug and branch.
|
|
71 |
||
72 |
Return None if there is no such link.
|
|
73 |
"""
|
|
74 |
||
12337.2.8
by Jeroen Vermeulen
Query more specifically for branches with visible bugs attached, to save time on unneeded work. |
75 |
def getBranchesWithVisibleBugs(branches, user): |
76 |
"""Find which of `branches` are for bugs that `user` can see.
|
|
4789.5.3
by Tim Penhey
Moved ObjectReassignmentView to avoid circular imports. |
77 |
|
12337.2.8
by Jeroen Vermeulen
Query more specifically for branches with visible bugs attached, to save time on unneeded work. |
78 |
:param branches: A sequence of `Branch`es to limit the search
|
79 |
to.
|
|
80 |
:return: A result set of `Branch` ids: a subset of the ids
|
|
81 |
found in `branches`, but limited to branches that are
|
|
82 |
visible to `user`.
|
|
4789.5.3
by Tim Penhey
Moved ObjectReassignmentView to avoid circular imports. |
83 |
"""
|
3755.4.1
by Tim Penhey
Basics working for IBugBranchSet |
84 |
|
3755.4.8
by Tim Penhey
modified the BatchNavigator callback method to also pass the BatchNavigator as the context, and updated the bug listing to use a single query to get the branches for the bug tasks |
85 |
def getBugBranchesForBugTasks(tasks): |
3755.4.4
by Tim Penhey
another BugBranchSet method for getting by bugs |
86 |
"""Return a sequence of IBugBranch instances associated with
|
3755.4.8
by Tim Penhey
modified the BatchNavigator callback method to also pass the BatchNavigator as the context, and updated the bug listing to use a single query to get the branches for the bug tasks |
87 |
the bugs for the given tasks."""
|