Merge lp:~brian-murray/launchpad/api-export-bug-activity into lp:launchpad

Proposed by Brian Murray
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 11608
Proposed branch: lp:~brian-murray/launchpad/api-export-bug-activity
Merge into: lp:launchpad
Diff against target: 159 lines (+86/-10)
4 files modified
lib/lp/bugs/browser/configure.zcml (+5/-0)
lib/lp/bugs/interfaces/bug.py (+6/-1)
lib/lp/bugs/interfaces/bugactivity.py (+44/-9)
lib/lp/bugs/stories/webservice/xx-bug.txt (+31/-0)
To merge this branch: bzr merge lp:~brian-murray/launchpad/api-export-bug-activity
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+35897@code.launchpad.net

Commit message

Export bug activity in the Launchpad API.

Description of the change

This branch exports bug activity in the Launchpad API, thereby allowing one to determine when and by whom a bug tag was added.

Tests modified:

bin/test -cvvt xx-bug.txt

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/configure.zcml'
2--- lib/lp/bugs/browser/configure.zcml 2010-09-06 15:14:17 +0000
3+++ lib/lp/bugs/browser/configure.zcml 2010-09-20 19:28:34 +0000
4@@ -531,6 +531,11 @@
5 permission="launchpad.View"
6 name="+activity"
7 template="../templates/bug-activity.pt"/>
8+ <browser:url
9+ for="lp.bugs.interfaces.bugactivity.IBugActivity"
10+ path_expression="string:activity"
11+ attribute_to_parent="bug"
12+ rootsite="bugs"/>
13 <browser:page
14 for="lp.bugs.interfaces.bugtask.IBugTask"
15 class="lp.bugs.browser.bugtask.BugTaskTableRowView"
16
17=== modified file 'lib/lp/bugs/interfaces/bug.py'
18--- lib/lp/bugs/interfaces/bug.py 2010-08-30 23:50:41 +0000
19+++ lib/lp/bugs/interfaces/bug.py 2010-09-20 19:28:34 +0000
20@@ -70,6 +70,7 @@
21 )
22 from canonical.launchpad.validators.name import name_validator
23 from lp.app.errors import NotFoundError
24+from lp.bugs.interfaces.bugactivity import IBugActivity
25 from lp.bugs.interfaces.bugattachment import IBugAttachment
26 from lp.bugs.interfaces.bugbranch import IBugBranch
27 from lp.bugs.interfaces.bugtask import (
28@@ -243,7 +244,11 @@
29 required=False, default=False, readonly=True))
30 displayname = TextLine(title=_("Text of the form 'Bug #X"),
31 readonly=True)
32- activity = Attribute('SQLObject.Multijoin of IBugActivity')
33+ activity = exported(
34+ CollectionField(
35+ title=_('Log of activity that has occurred on this bug.'),
36+ value_type=Reference(schema=IBugActivity),
37+ readonly=True))
38 initial_message = Attribute(
39 "The message that was specified when creating the bug")
40 bugtasks = exported(
41
42=== modified file 'lib/lp/bugs/interfaces/bugactivity.py'
43--- lib/lp/bugs/interfaces/bugactivity.py 2010-08-20 20:31:18 +0000
44+++ lib/lp/bugs/interfaces/bugactivity.py 2010-09-20 19:28:34 +0000
45@@ -15,24 +15,59 @@
46 from zope.interface import Interface
47 from zope.schema import (
48 Datetime,
49- Int,
50 Text,
51 TextLine,
52 )
53
54+from lazr.restful.declarations import (
55+ export_as_webservice_entry,
56+ exported,
57+ )
58+
59+from lp.services.fields import (
60+ BugField,
61+ PersonChoice,
62+ )
63+
64 from canonical.launchpad import _
65
66
67 class IBugActivity(Interface):
68 """A log of all things that have happened to a bug."""
69-
70- bug = Int(title=_('Bug ID'))
71- datechanged = Datetime(title=_('Date Changed'))
72- person = Int(title=_('Person'))
73- whatchanged = TextLine(title=_('What Changed'))
74- oldvalue = TextLine(title=_('Old Value'))
75- newvalue = TextLine(title=_('New Value'))
76- message = Text(title=_('Message'))
77+ export_as_webservice_entry()
78+
79+ bug = exported(
80+ BugField(title=_('Bug'), readonly=True))
81+
82+ datechanged = exported(
83+ Datetime(title=_('Date Changed'),
84+ description=_("The date on which this activity occurred."),
85+ readonly=True))
86+
87+ person = exported(PersonChoice(
88+ title=_('Person'), required=True, vocabulary='ValidPersonOrTeam',
89+ readonly=True, description=_("The person's Launchpad ID or "
90+ "e-mail address.")))
91+
92+ whatchanged = exported(
93+ TextLine(title=_('What Changed'),
94+ description=_("The property of the bug that changed."),
95+ readonly=True))
96+
97+ oldvalue = exported(
98+ TextLine(title=_('Old Value'),
99+ description=_("The value before the change."),
100+ readonly=True))
101+
102+ newvalue = exported(
103+ TextLine(title=_('New Value'),
104+ description=_("The value after the change."),
105+ readonly=True))
106+
107+ message = exported(
108+ Text(title=_('Message'),
109+ description=_("Additional information about what changed."),
110+ readonly=True))
111
112
113 class IBugActivitySet(Interface):
114
115=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
116--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-09-03 20:28:36 +0000
117+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-09-20 19:28:34 +0000
118@@ -18,6 +18,7 @@
119 15
120 >>> bug_entries = sorted(bugs['entries'], key=itemgetter('id'))
121 >>> pprint_entry(bug_entries[0])
122+ activity_collection_link: u'http://.../bugs/11/activity'
123 attachments_collection_link: u'http://.../bugs/11/attachments'
124 bug_tasks_collection_link: u'http://.../bugs/11/bug_tasks'
125 bug_watches_collection_link: u'http://.../bugs/11/bug_watches'
126@@ -2084,3 +2085,33 @@
127 Traceback (most recent call last):
128 ...
129 NameError: name 'can_expire' is not defined
130+
131+
132+Bug activity
133+------------
134+
135+Each bug has a collection of activities that have taken place with it.
136+
137+ >>> from lazr.restful.testing.webservice import (
138+ ... pprint_collection, pprint_entry)
139+ >>> activity = webservice.get(
140+ ... bug_one['activity_collection_link']).jsonBody()
141+ >>> pprint_collection(activity)
142+ next_collection_link: u'http://.../bugs/1/activity?ws.start=5&ws.size=5'
143+ resource_type_link: u'http://.../#bug_activity-page-resource'
144+ start: 0
145+ total_size: 26
146+ ...
147+
148+ >>> bug_nine_activity = webservice.get(
149+ ... "/bugs/9/activity").jsonBody()
150+ >>> pprint_entry(bug_nine_activity['entries'][1])
151+ bug_link: u'http://.../bugs/9'
152+ datechanged: u'2006-02-23T16:42:40.288553+00:00'
153+ message: None
154+ newvalue: u'Confirmed'
155+ oldvalue: u'Unconfirmed'
156+ person_link: u'http://.../~name12'
157+ resource_type_link: u'http://.../#bug_activity'
158+ self_link: u'http://.../bugs/9/activity'
159+ whatchanged: u'thunderbird: status'