def _q_lookup(self, request, comment_id): comment = TicketComment.get(id=comment_id) if not comment: raise TraversalError( "Unable to find pr_comment %s" % comment_id) else: self.pr_comment = comment return self
def edit(self, request): user = request.user current_user = request.user project = CodeDoubanProject.get_by_name(self.proj_name) content = request.get_form_var( 'pull_request_comment', '').decode('utf-8') if self.pr_comment.author == user.name: self.pr_comment.update(content) comment = TicketComment.get(id=self.pr_comment.id) author = user return dict(r=0, html=st('/pull/ticket_comment.html', **locals())) return {'r': 1}
def test_ticket_comment(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) # add ticket comment comment = p1_t1.add_comment('comment contet', author) assert comment is not None # update ticket_comment assert comment.content == 'comment contet' comment.update('comment content updated') comment = TicketComment.get(id=comment.id) assert comment.content == 'comment content updated' # delete ticket_comment assert len(TicketComment.gets_by_ticketid(p1_t1.id)) == 1 comment.delete() assert TicketComment.gets_by_ticketid(p1_t1.id) == []
def test_ticket_comment(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) # add ticket comment comment = p1_t1.add_comment('comment contet', author) assert comment is not None # update ticket_comment assert comment.content == 'comment contet' comment.update('comment content updated') comment = TicketComment.get(id=comment.id) assert comment.content == 'comment content updated' # delete ticket_comment assert len(TicketComment.gets_by_ticketid(p1_t1.id)) == 1 comment.delete() assert TicketComment.gets_by_ticketid(p1_t1.id) == []