~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
= Bug message visibility =

Bug messages have a visible field, which provides a means
for hiding messages rather than having to delete them.

A bug message has a visible field, which is True by default.

    # Setup for creating a new message
    >>> from lp.bugs.interfaces.bug import IBugSet
    >>> from lp.bugs.interfaces.bugmessage import IBugMessageSet
    >>> from lp.registry.interfaces.person import IPersonSet

    >>> bugmessageset = getUtility(IBugMessageSet)
    >>> sample_person = getUtility(IPersonSet).get(12)
    >>> bug_one = getUtility(IBugSet).get(1)

    # New messages are visible by default.
    >>> new_message = bugmessageset.createMessage(
    ...     subject="new message for visibility test",
    ...     content="new message for visibility test",
    ...     owner=sample_person,
    ...     bug=bug_one)
    >>> new_message.message.visible
    True

Only Admins and registry experts can hide bug messages using the visible
field.

    # Login an Admin user and set visible to False.
    >>> login('foo.bar@canonical.com')
    >>> abugmessage = bugmessageset.get(1)
    >>> abugmessage.message.visible
    True
    >>> abugmessage.message.visible = False
    >>> abugmessage.message.visible
    False

    # Non-privileged users should not be able to
    # make comments visible again.
    >>> login('no-priv@canonical.com')
    >>> abugmessage = bugmessageset.get(1)
    >>> abugmessage.message.visible
    False
    >>> abugmessage.message.visible = True
    Traceback (most recent call last):
    ...
    Unauthorized: (<Message at ...>, 'visible', 'launchpad.Admin')