OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from oauth2client.client import SignedJwtAssertionCredentials | 5 from oauth2client.client import SignedJwtAssertionCredentials |
6 import httplib2 | 6 import httplib2 |
7 import model.app_config | 7 import model.app_config |
8 import urllib | 8 import urllib |
9 import util | 9 import util |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 def post_data(self, req, payload=None): | 59 def post_data(self, req, payload=None): |
60 actual_payload = dict(payload or {}) | 60 actual_payload = dict(payload or {}) |
61 actual_payload['xsrf_token'] = self.xsrf_token | 61 actual_payload['xsrf_token'] = self.xsrf_token |
62 | 62 |
63 return self.make_request(req, method='POST', | 63 return self.make_request(req, method='POST', |
64 body=urllib.urlencode(actual_payload)) | 64 body=urllib.urlencode(actual_payload)) |
65 | 65 |
66 def post_issue_data(self, issue, req, payload): | 66 def post_issue_data(self, issue, req, payload): |
67 return self.post_data('%s/%s' % (issue, req), payload) | 67 return self.post_data('%s/%s' % (issue, req), payload) |
68 | 68 |
69 def post_comment(self, issue, comment, submit_inline_comments=False): | 69 def publish_inline_comments(self, issue, comment, reviewers, cc, |
| 70 subject=None, send_mail=False): |
70 publish_payload = { | 71 publish_payload = { |
71 'message_only': 0 if submit_inline_comments else 1, | 72 'cc': cc, |
72 'send_mail': 1, | |
73 'add_as_reviewer': 0, | |
74 'message': comment, | 73 'message': comment, |
| 74 'message_only': 0, |
75 'no_redirect': 1, | 75 'no_redirect': 1, |
| 76 'reviewers': reviewers, |
| 77 'send_mail': 1 if send_mail else 0, |
76 } | 78 } |
| 79 if subject is not None: |
| 80 publish_payload['subject'] = subject |
77 self.post_issue_data(issue, 'publish', publish_payload) | 81 self.post_issue_data(issue, 'publish', publish_payload) |
78 | 82 |
79 def add_inline_comment(self, issue_id, patchset_id, patch_id, line, a_or_b, | 83 def add_inline_comment(self, issue_id, patchset_id, patch_id, line, a_or_b, |
80 comment): | 84 comment): |
81 comment_payload = { | 85 comment_payload = { |
82 'snapshot': 'old' if a_or_b is 'a' else 'new', | 86 'snapshot': 'old' if a_or_b is 'a' else 'new', |
83 'lineno': line, | 87 'lineno': line, |
84 'side': a_or_b, | 88 'side': a_or_b, |
85 'issue': issue_id, | 89 'issue': issue_id, |
86 'patchset': patchset_id, | 90 'patchset': patchset_id, |
87 'patch': patch_id, | 91 'patch': patch_id, |
88 'text': comment, | 92 'text': comment, |
89 } | 93 } |
90 self.post_data('inline_draft', comment_payload) | 94 self.post_data('inline_draft', comment_payload) |
OLD | NEW |