launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01100
[Merge] lp:~brian-murray/launchpad/api-export-bug-activity into lp:launchpad/devel
Brian Murray has proposed merging lp:~brian-murray/launchpad/api-export-bug-activity into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
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
--
https://code.launchpad.net/~brian-murray/launchpad/api-export-bug-activity/+merge/35897
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~brian-murray/launchpad/api-export-bug-activity into lp:launchpad/devel.
=== 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-17 22:37:50 +0000
@@ -531,6 +531,11 @@
permission="launchpad.View"
name="+activity"
template="../templates/bug-activity.pt"/>
+ <browser:url
+ for="lp.bugs.interfaces.bugactivity.IBugActivity"
+ path_expression="string:activity"
+ attribute_to_parent="bug"
+ rootsite="bugs"/>
<browser:page
for="lp.bugs.interfaces.bugtask.IBugTask"
class="lp.bugs.browser.bugtask.BugTaskTableRowView"
=== 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-17 22:37:50 +0000
@@ -70,6 +70,7 @@
)
from canonical.launchpad.validators.name import name_validator
from lp.app.errors import NotFoundError
+from lp.bugs.interfaces.bugactivity import IBugActivity
from lp.bugs.interfaces.bugattachment import IBugAttachment
from lp.bugs.interfaces.bugbranch import IBugBranch
from lp.bugs.interfaces.bugtask import (
@@ -243,7 +244,11 @@
required=False, default=False, readonly=True))
displayname = TextLine(title=_("Text of the form 'Bug #X"),
readonly=True)
- activity = Attribute('SQLObject.Multijoin of IBugActivity')
+ activity = exported(
+ CollectionField(
+ title=_('Log of activity that has occurred on this bug.'),
+ value_type=Reference(schema=IBugActivity),
+ readonly=True))
initial_message = Attribute(
"The message that was specified when creating the bug")
bugtasks = exported(
=== 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-17 22:37:50 +0000
@@ -15,24 +15,53 @@
from zope.interface import Interface
from zope.schema import (
Datetime,
- Int,
Text,
TextLine,
)
+from lazr.restful.declarations import (
+ export_as_webservice_entry,
+ exported,
+ )
+
+from lp.services.fields import (
+ BugField,
+ PersonChoice,
+ )
+
from canonical.launchpad import _
class IBugActivity(Interface):
"""A log of all things that have happened to a bug."""
+ export_as_webservice_entry()
- bug = Int(title=_('Bug ID'))
- datechanged = Datetime(title=_('Date Changed'))
- person = Int(title=_('Person'))
- whatchanged = TextLine(title=_('What Changed'))
- oldvalue = TextLine(title=_('Old Value'))
- newvalue = TextLine(title=_('New Value'))
- message = Text(title=_('Message'))
+ bug = exported(
+ BugField(title=_('Bug ID'), readonly=True))
+ datechanged = exported(
+ Datetime(title=_('Date Changed'),
+ description=_("The date on which this activity occurred."),
+ readonly=True))
+ person = exported(PersonChoice(
+ title=_('Person'), required=True, vocabulary='ValidPersonOrTeam',
+ readonly=True, description=_("The person's Launchpad ID or "
+ "e-mail address.")))
+ whatchanged = exported(
+ TextLine(title=_('What Changed'),
+ description=_("The property of the bug that changed."),
+ readonly=True))
+ oldvalue = exported(
+ TextLine(title=_('Old Value'),
+ description=_("The value before the change."),
+ readonly=True))
+ newvalue = exported(
+ TextLine(title=_('New Value'),
+ description=_("The value after the change."),
+ readonly=True))
+ message = exported(
+ Text(title=_('Message'),
+ description=_("The related property of the bug that changed."),
+ readonly=True))
class IBugActivitySet(Interface):
=== 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-17 22:37:50 +0000
@@ -18,6 +18,7 @@
15
>>> bug_entries = sorted(bugs['entries'], key=itemgetter('id'))
>>> pprint_entry(bug_entries[0])
+ activity_collection_link: u'http://.../bugs/11/activity'
attachments_collection_link: u'http://.../bugs/11/attachments'
bug_tasks_collection_link: u'http://.../bugs/11/bug_tasks'
bug_watches_collection_link: u'http://.../bugs/11/bug_watches'
@@ -2084,3 +2085,38 @@
Traceback (most recent call last):
...
NameError: name 'can_expire' is not defined
+
+
+Bug activity
+------------
+
+Each bug has a collection of activities that have taken place with it.
+
+ >>> from lazr.restful.testing.webservice import (
+ ... pprint_collection, pprint_entry)
+ >>> activity = webservice.get(
+ ... bug_one['activity_collection_link']).jsonBody()
+ >>> pprint_collection(activity)
+ next_collection_link: u'http://.../bugs/1/activity?ws.start=5&ws.size=5'
+ resource_type_link: u'http://.../#bug_activity-page-resource'
+ start: 0
+ total_size: 26
+ ...
+
+ >>> bug_nine_activity = webservice.get(
+ ... "/bugs/9/activity").jsonBody()
+ >>> pprint_entry(bug_nine_activity['entries'][1])
+ bug_link: u'http://.../bugs/9'
+ datechanged: u'2006-02-23T16:42:40.288553+00:00'
+ message: None
+ newvalue: u'Confirmed'
+ oldvalue: u'Unconfirmed'
+ person_link: u'http://.../~name12'
+ resource_type_link: u'http://.../#bug_activity'
+ self_link: u'http://.../bugs/9/activity'
+ whatchanged: u'thunderbird: status'
+
+The collection of bug tasks is not exposed as a resource:
+
+ >>> webservice.get("/activity").status
+ 404