Merge lp:~thumper/launchpad/yet-more-api-exports into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~thumper/launchpad/yet-more-api-exports
Merge into: lp:launchpad
Diff against target: 87 lines (+25/-1)
3 files modified
lib/lp/code/interfaces/codereviewcomment.py (+9/-1)
lib/lp/code/model/codereviewcomment.py (+10/-0)
lib/lp/code/stories/webservice/xx-branchmergeproposal.txt (+6/-0)
To merge this branch: bzr merge lp:~thumper/launchpad/yet-more-api-exports
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+23905@code.launchpad.net

Commit message

Expose the date created and author of code review comments over the api.

Description of the change

A very simple branch that exposes two more attributes of the code review comment.

Since we are still trying out how to best use the launchpadlib in tests, I've just added the attributes to the current webservice doctest.

tests:
  stories/webservice/xx-branchmergeproposal.txt

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/interfaces/codereviewcomment.py'
2--- lib/lp/code/interfaces/codereviewcomment.py 2009-10-21 17:45:53 +0000
3+++ lib/lp/code/interfaces/codereviewcomment.py 2010-04-22 10:27:34 +0000
4@@ -12,12 +12,13 @@
5 ]
6
7 from zope.interface import Interface
8-from zope.schema import Choice, Object, Int, TextLine
9+from zope.schema import Choice, Datetime, Int, Object, TextLine
10
11 from canonical.launchpad import _
12 from lp.code.enums import CodeReviewVote
13 from lp.code.interfaces.branchmergeproposal import (
14 IBranchMergeProposal)
15+from lp.registry.interfaces.person import IPerson
16 from canonical.launchpad.interfaces.message import IMessage
17 from lazr.restful.fields import Reference
18 from lazr.restful.declarations import (
19@@ -40,6 +41,13 @@
20
21 message = Object(schema=IMessage, title=_('The message.'))
22
23+ author = exported(
24+ Reference(title=_('Comment Author'), schema=IPerson,
25+ required=True, readonly=True))
26+
27+ date_created = exported(
28+ Datetime(title=_('Date Created'), required=True, readonly=True))
29+
30 vote = exported(
31 Choice(
32 title=_('Review'), required=False,
33
34=== modified file 'lib/lp/code/model/codereviewcomment.py'
35--- lib/lp/code/model/codereviewcomment.py 2009-10-21 17:45:53 +0000
36+++ lib/lp/code/model/codereviewcomment.py 2010-04-22 10:27:34 +0000
37@@ -75,6 +75,16 @@
38 vote_tag = StringCol(default=None)
39
40 @property
41+ def author(self):
42+ """Defer to the related message."""
43+ return self.message.owner
44+
45+ @property
46+ def date_created(self):
47+ """Defer to the related message."""
48+ return self.message.datecreated
49+
50+ @property
51 def target(self):
52 """See `IHasBranchTarget`."""
53 return self.branch_merge_proposal.target
54
55=== modified file 'lib/lp/code/stories/webservice/xx-branchmergeproposal.txt'
56--- lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-04-13 15:12:18 +0000
57+++ lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-04-22 10:27:34 +0000
58@@ -180,7 +180,9 @@
59 2
60 >>> pprint_entry(all_comments['entries'][0])
61 as_quoted_email: u'> This is great work'
62+ author_link: u'http://api.launchpad.dev/devel/~...'
63 branch_merge_proposal_link: u'http://.../~source/fooix/fix-it/+merge/...'
64+ date_created: u'...'
65 id: ...
66 message_body: u'This is great work'
67 resource_type_link: u'http://.../#code_review_comment'
68@@ -193,7 +195,9 @@
69 ... merge_proposal['self_link'], 'getComment', id=2).jsonBody()
70 >>> pprint_entry(comment_2)
71 as_quoted_email: u'> This is mediocre work.'
72+ author_link: u'http://api.launchpad.dev/devel/~...'
73 branch_merge_proposal_link: u'http://.../~source/fooix/fix-it/+merge/...'
74+ date_created: u'...'
75 id: ...
76 message_body: u'This is mediocre work.'
77 resource_type_link: u'http://.../#code_review_comment'
78@@ -264,7 +268,9 @@
79 >>> comment = reviewer_webservice.get(comment_link).jsonBody()
80 >>> pprint_entry(comment)
81 as_quoted_email: u'> This is great work'
82+ author_link: u'http://api.launchpad.dev/devel/~...'
83 branch_merge_proposal_link: u'http://.../~source/fooix/fix-it/+merge/...'
84+ date_created: u'...'
85 id: ...
86 message_body: u'This is great work'
87 resource_type_link: u'http://.../#code_review_comment'