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
=== modified file 'lib/lp/bugs/browser/configure.zcml'
--- lib/lp/bugs/browser/configure.zcml 2010-09-06 15:14:17 +0000
+++ lib/lp/bugs/browser/configure.zcml 2010-09-20 19:28:34 +0000
@@ -531,6 +531,11 @@
531 permission="launchpad.View"531 permission="launchpad.View"
532 name="+activity"532 name="+activity"
533 template="../templates/bug-activity.pt"/>533 template="../templates/bug-activity.pt"/>
534 <browser:url
535 for="lp.bugs.interfaces.bugactivity.IBugActivity"
536 path_expression="string:activity"
537 attribute_to_parent="bug"
538 rootsite="bugs"/>
534 <browser:page539 <browser:page
535 for="lp.bugs.interfaces.bugtask.IBugTask"540 for="lp.bugs.interfaces.bugtask.IBugTask"
536 class="lp.bugs.browser.bugtask.BugTaskTableRowView"541 class="lp.bugs.browser.bugtask.BugTaskTableRowView"
537542
=== modified file 'lib/lp/bugs/interfaces/bug.py'
--- lib/lp/bugs/interfaces/bug.py 2010-08-30 23:50:41 +0000
+++ lib/lp/bugs/interfaces/bug.py 2010-09-20 19:28:34 +0000
@@ -70,6 +70,7 @@
70 )70 )
71from canonical.launchpad.validators.name import name_validator71from canonical.launchpad.validators.name import name_validator
72from lp.app.errors import NotFoundError72from lp.app.errors import NotFoundError
73from lp.bugs.interfaces.bugactivity import IBugActivity
73from lp.bugs.interfaces.bugattachment import IBugAttachment74from lp.bugs.interfaces.bugattachment import IBugAttachment
74from lp.bugs.interfaces.bugbranch import IBugBranch75from lp.bugs.interfaces.bugbranch import IBugBranch
75from lp.bugs.interfaces.bugtask import (76from lp.bugs.interfaces.bugtask import (
@@ -243,7 +244,11 @@
243 required=False, default=False, readonly=True))244 required=False, default=False, readonly=True))
244 displayname = TextLine(title=_("Text of the form 'Bug #X"),245 displayname = TextLine(title=_("Text of the form 'Bug #X"),
245 readonly=True)246 readonly=True)
246 activity = Attribute('SQLObject.Multijoin of IBugActivity')247 activity = exported(
248 CollectionField(
249 title=_('Log of activity that has occurred on this bug.'),
250 value_type=Reference(schema=IBugActivity),
251 readonly=True))
247 initial_message = Attribute(252 initial_message = Attribute(
248 "The message that was specified when creating the bug")253 "The message that was specified when creating the bug")
249 bugtasks = exported(254 bugtasks = exported(
250255
=== modified file 'lib/lp/bugs/interfaces/bugactivity.py'
--- lib/lp/bugs/interfaces/bugactivity.py 2010-08-20 20:31:18 +0000
+++ lib/lp/bugs/interfaces/bugactivity.py 2010-09-20 19:28:34 +0000
@@ -15,24 +15,59 @@
15from zope.interface import Interface15from zope.interface import Interface
16from zope.schema import (16from zope.schema import (
17 Datetime,17 Datetime,
18 Int,
19 Text,18 Text,
20 TextLine,19 TextLine,
21 )20 )
2221
22from lazr.restful.declarations import (
23 export_as_webservice_entry,
24 exported,
25 )
26
27from lp.services.fields import (
28 BugField,
29 PersonChoice,
30 )
31
23from canonical.launchpad import _32from canonical.launchpad import _
2433
2534
26class IBugActivity(Interface):35class IBugActivity(Interface):
27 """A log of all things that have happened to a bug."""36 """A log of all things that have happened to a bug."""
2837 export_as_webservice_entry()
29 bug = Int(title=_('Bug ID'))38
30 datechanged = Datetime(title=_('Date Changed'))39 bug = exported(
31 person = Int(title=_('Person'))40 BugField(title=_('Bug'), readonly=True))
32 whatchanged = TextLine(title=_('What Changed'))41
33 oldvalue = TextLine(title=_('Old Value'))42 datechanged = exported(
34 newvalue = TextLine(title=_('New Value'))43 Datetime(title=_('Date Changed'),
35 message = Text(title=_('Message'))44 description=_("The date on which this activity occurred."),
45 readonly=True))
46
47 person = exported(PersonChoice(
48 title=_('Person'), required=True, vocabulary='ValidPersonOrTeam',
49 readonly=True, description=_("The person's Launchpad ID or "
50 "e-mail address.")))
51
52 whatchanged = exported(
53 TextLine(title=_('What Changed'),
54 description=_("The property of the bug that changed."),
55 readonly=True))
56
57 oldvalue = exported(
58 TextLine(title=_('Old Value'),
59 description=_("The value before the change."),
60 readonly=True))
61
62 newvalue = exported(
63 TextLine(title=_('New Value'),
64 description=_("The value after the change."),
65 readonly=True))
66
67 message = exported(
68 Text(title=_('Message'),
69 description=_("Additional information about what changed."),
70 readonly=True))
3671
3772
38class IBugActivitySet(Interface):73class IBugActivitySet(Interface):
3974
=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-09-03 20:28:36 +0000
+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-09-20 19:28:34 +0000
@@ -18,6 +18,7 @@
18 1518 15
19 >>> bug_entries = sorted(bugs['entries'], key=itemgetter('id'))19 >>> bug_entries = sorted(bugs['entries'], key=itemgetter('id'))
20 >>> pprint_entry(bug_entries[0])20 >>> pprint_entry(bug_entries[0])
21 activity_collection_link: u'http://.../bugs/11/activity'
21 attachments_collection_link: u'http://.../bugs/11/attachments'22 attachments_collection_link: u'http://.../bugs/11/attachments'
22 bug_tasks_collection_link: u'http://.../bugs/11/bug_tasks'23 bug_tasks_collection_link: u'http://.../bugs/11/bug_tasks'
23 bug_watches_collection_link: u'http://.../bugs/11/bug_watches'24 bug_watches_collection_link: u'http://.../bugs/11/bug_watches'
@@ -2084,3 +2085,33 @@
2084 Traceback (most recent call last):2085 Traceback (most recent call last):
2085 ...2086 ...
2086 NameError: name 'can_expire' is not defined2087 NameError: name 'can_expire' is not defined
2088
2089
2090Bug activity
2091------------
2092
2093Each bug has a collection of activities that have taken place with it.
2094
2095 >>> from lazr.restful.testing.webservice import (
2096 ... pprint_collection, pprint_entry)
2097 >>> activity = webservice.get(
2098 ... bug_one['activity_collection_link']).jsonBody()
2099 >>> pprint_collection(activity)
2100 next_collection_link: u'http://.../bugs/1/activity?ws.start=5&ws.size=5'
2101 resource_type_link: u'http://.../#bug_activity-page-resource'
2102 start: 0
2103 total_size: 26
2104 ...
2105
2106 >>> bug_nine_activity = webservice.get(
2107 ... "/bugs/9/activity").jsonBody()
2108 >>> pprint_entry(bug_nine_activity['entries'][1])
2109 bug_link: u'http://.../bugs/9'
2110 datechanged: u'2006-02-23T16:42:40.288553+00:00'
2111 message: None
2112 newvalue: u'Confirmed'
2113 oldvalue: u'Unconfirmed'
2114 person_link: u'http://.../~name12'
2115 resource_type_link: u'http://.../#bug_activity'
2116 self_link: u'http://.../bugs/9/activity'
2117 whatchanged: u'thunderbird: status'