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 comments(self, request): if request.method == 'POST': return self.add_qaci_comment(request) comments = TicketComment.gets_by_ticketid(self.ticket.id) cl = [] for c in comments: cl.append(c.as_dict()) return cl
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) == []
def get_commented_ticket_ids_in_others_merged_PR_by_date(cls, username, given_date, limit=500, start=0): others_merged_PR_ids = cls._iter_others_merged_PR_ids_by_date(username, given_date, limit=limit, start=start) ticket_comment_list = ((tid, TicketComment.gets_by_ticketid(tid)) for tid in others_merged_PR_ids) get_authors_comments = lambda comments: [c for c in comments if c.author == username] ticket_ids_and_commented_count = ( (tid, len(get_authors_comments(comments))) for tid, comments in ticket_comment_list ) user_commented_ticket_ids_and_commented_count = [ (tid, cnt) for tid, cnt in ticket_ids_and_commented_count if cnt > 0 ] return user_commented_ticket_ids_and_commented_count
def get_commented_ticket_ids_in_others_merged_PR_by_date( cls, username, given_date, limit=500, start=0): others_merged_PR_ids = cls._iter_others_merged_PR_ids_by_date( username, given_date, limit=limit, start=start) ticket_comment_list = ((tid, TicketComment.gets_by_ticketid( tid)) for tid in others_merged_PR_ids) get_authors_comments = lambda comments: [ c for c in comments if c.author == username] ticket_ids_and_commented_count = ((tid, len(get_authors_comments( comments))) for tid, comments in ticket_comment_list) user_commented_ticket_ids_and_commented_count = [ (tid, cnt) for tid, cnt in ticket_ids_and_commented_count if cnt > 0] return user_commented_ticket_ids_and_commented_count