def _q_lookup(self, request, comment_id): comment = PullLineComment.get(comment_id) if not comment: raise TraversalError("Unable to find comment %s" % comment_id) else: self.code_review = comment return self
def _q_lookup(self, request, comment_id): comment = PullLineComment.get(comment_id) if not comment: raise TraversalError( "Unable to find comment %s" % comment_id) else: self.code_review = comment return self
def edit(self, request): user = request.user project = CodeDoubanProject.get_by_name(self.proj_name) content = request.get_form_var( 'pull_request_review_comment', '').decode('utf-8') if self.code_review.author == user.name: self.code_review.update(content) linecomment = PullLineComment.get(self.code_review.id) pullreq = True return dict( r=0, html=st('/pull/ticket_linecomment.html', **locals())) return dict(r=1)
def edit(self, request): user = request.user project = CodeDoubanProject.get_by_name(self.proj_name) content = request.get_form_var('pull_request_review_comment', '').decode('utf-8') if self.code_review.author == user.name: self.code_review.update(content) linecomment = PullLineComment.get(self.code_review.id) pullreq = True return dict(r=0, html=st('/pull/ticket_linecomment.html', **locals())) return dict(r=1)
def test_ticket_code_review(self): title = 'test title' desc = 'test desc' author = 'testuser' p1_t1 = Ticket.add(self.proj1.id, title, desc, author) pullreq1 = PullRequest.open(self.proj1_fork, 'master', self.proj1, 'master') pullreq1 = pullreq1.insert(p1_t1.ticket_number) # ticket code review path = '/README.md' #position = 10 from_sha = '454418c61cd7ef1a65818121746b45064a5af5d6' oid = '454418c61cd7ef1a65818121746b45064a5af5d6' codereview = p1_t1.add_codereview(from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'comment content') assert codereview.ticket_id == p1_t1.id assert codereview.path == path assert codereview.from_sha == from_sha # test update content assert codereview.content == 'comment content' codereview.update('content updated') codereview = PullLineComment.get(codereview.id) assert codereview.content == 'content updated' codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1 p1_t1.add_codereview(from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'another comment content') codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 2 # test delete comment codereview.delete() codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1
def test_ticket_code_review(self): title = 'test title' desc = 'test desc' author = 'testuser' p1_t1 = Ticket.add(self.proj1.id, title, desc, author) pullreq1 = PullRequest.open( self.proj1_fork, 'master', self.proj1, 'master') pullreq1 = pullreq1.insert(p1_t1.ticket_number) # ticket code review path = '/README.md' #position = 10 from_sha = '454418c61cd7ef1a65818121746b45064a5af5d6' oid = '454418c61cd7ef1a65818121746b45064a5af5d6' codereview = p1_t1.add_codereview( from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'comment content') assert codereview.ticket_id == p1_t1.id assert codereview.path == path assert codereview.from_sha == from_sha #test update content assert codereview.content == 'comment content' codereview.update('content updated') codereview = PullLineComment.get(codereview.id) assert codereview.content == 'content updated' codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1 p1_t1.add_codereview( from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'another comment content') codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 2 #test delete comment codereview.delete() codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1
def codereview(self): if self.type == TICKET_NODE_TYPE_LINECOMMENT: return PullLineComment.get(self.type_id)
def codereview(self): if self.type == TICKET_NODE_TYPE_LINECOMMENT: return PullLineComment.get(self.type_id)