~launchpad-pqm/launchpad/devel

11678.5.10 by Deryck Hodge
Make a better document. Requires a new unit test for canTransitionToStatus.
1
Changing Bug Task Status
2
========================
3
4
Restrictions
5
------------
6
7
There are a few simple rules around who can change the status of a
8
bug task.  There are three statuses that can only be set by either
9
the project registrant or the bug supervisor:
10
11
 * Won't Fix
12
 * Expired
13
 * Triaged
14
11678.5.17 by Deryck Hodge
Add some code back to the doctest so it has complete examples.
15
    >>> owner = factory.makePerson()
16
    >>> product = factory.makeProduct(owner=owner)
17
    >>> bugtask = factory.makeBugTask(target=product)
18
    >>> user = factory.makePerson()
19
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
20
    >>> from lp.bugs.interfaces.bugtask import BugTaskStatus
11678.5.17 by Deryck Hodge
Add some code back to the doctest so it has complete examples.
21
    >>> login_person(owner)
22
    >>> bugtask.transitionToStatus(BugTaskStatus.WONTFIX, owner)
23
    >>> print bugtask.status.title
24
    Won't Fix
25
11678.5.10 by Deryck Hodge
Make a better document. Requires a new unit test for canTransitionToStatus.
26
Regular users of Launchpad cannot transition a bug task to any of
27
these statuses.
28
29
An additional restraint is added to Won't Fix.  Only the product
30
registrant or bug supervisor can change from this status to any
31
other status.
32
11678.5.17 by Deryck Hodge
Add some code back to the doctest so it has complete examples.
33
    >>> login_person(user)
34
    >>> bugtask.transitionToStatus(BugTaskStatus.CONFIRMED, user)
35
    Traceback (most recent call last):
36
    ...
37
    UserCannotEditBugTaskStatus...
38
39
This is fully tested in
40
lp.bugs.tests.test_bugtask_status.TestBugTaskStatusSetting.
11678.5.10 by Deryck Hodge
Make a better document. Requires a new unit test for canTransitionToStatus.
41
42
Testing for Permission
43
----------------------
10606.3.1 by Colin Watson
restrict transitions away from wontfix to bug supervisors
44
4318.3.21 by Gavin Panella
Address bug-workflow-4 review comments from kiko.
45
The method IBugTask.canTransitionToStatus comes in handy here. It
46
tells us if a transition to a status is permitted. It is *not* a
11678.5.10 by Deryck Hodge
Make a better document. Requires a new unit test for canTransitionToStatus.
47
dry-run of IBugTask.transitionToStatus, but is good enough and fast
48
enough to be used by UI code, e.g. to display only those statuses to
49
which a user can transition a particular bugtask.
50
11678.5.17 by Deryck Hodge
Add some code back to the doctest so it has complete examples.
51
    >>> bugtask.canTransitionToStatus(BugTaskStatus.TRIAGED, owner)
4318.3.21 by Gavin Panella
Address bug-workflow-4 review comments from kiko.
52
    True
11678.5.17 by Deryck Hodge
Add some code back to the doctest so it has complete examples.
53
    >>> bugtask.canTransitionToStatus(BugTaskStatus.TRIAGED, user)
10606.3.1 by Colin Watson
restrict transitions away from wontfix to bug supervisors
54
    False
11678.5.10 by Deryck Hodge
Make a better document. Requires a new unit test for canTransitionToStatus.
55
56
This method is fully tested in
57
lp.bugs.tests.test_bugtask_status.TestCanTransitionToStatus.