示例#1
0
def format_issue_comment_info(**kw):
    from vilya.models.issue_comment import IssueComment
    issue_id = kw['issue_id']
    author = kw['author']
    content = kw['content']
    comment_id = kw['comment_id']

    issue = get_issue_by_issue_id(issue_id)
    target = issue.target

    issue_comment = IssueComment.get(comment_id)
    text = trunc_utf8(content, 50)
    uid = "issue-comment-%s-%s-%s-%s" % (issue.target_type, target.id,
                                         issue.number, issue_comment.number)
    type = 'issue_comment'
    data = dict(
        date=datetime.now(),
        url="%s#comment-%s" % (issue.url, issue_comment.number),
        number=issue.number,
        title=issue.title,
        target_name="%s" % target.name,
        target_url="%s" % target.url,
        receiver=issue.creator_id,
        author=author,
        text=text,
        uid=uid,
        type=type,
    )
    return data
示例#2
0
文件: team.py 项目: leeccong/code
 def _q_lookup(self, request, comment_id):
     comment = IssueComment.get(comment_id)
     if not comment:
         raise TraversalError("Unable to find issue comment %s" % comment_id)
     else:
         self.comment = comment
         return self
示例#3
0
 def test_update_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     c.update('content1')
     c = IssueComment.get(c.id)
     assert c.issue_id == i.id
     assert c.content == 'content1'
     assert c.author_id == 'test'
示例#4
0
文件: issue.py 项目: jackfrued/code-1
 def _q_lookup(self, request, comment_id):
     comment = IssueComment.get(comment_id)
     if not comment:
         raise TraversalError("Unable to find issue comment %s" %
                              comment_id)
     else:
         self.comment = comment
         return self
示例#5
0
 def test_update_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     c.update('content1')
     c = IssueComment.get(c.id)
     assert c.issue_id == i.id
     assert c.content == 'content1'
     assert c.author_id == 'test'
示例#6
0
    def test_get_comment(self):
        i = Issue.add('test', 'test description', 'test', 'assignee')
        c = IssueComment.add(i.id, 'content', 'test')
        c = IssueComment.get(c.id)
        assert isinstance(c, IssueComment)
        assert c.issue_id == i.id
        assert c.content == 'content'
        assert c.author_id == 'test'

        c = IssueComment.add(i.id, 'content', 'test')
        cs = IssueComment.gets_by_issue_id(i.id)
        assert all([isinstance(t, IssueComment) for t in cs])
        assert len(cs) == 2
示例#7
0
    def test_get_comment(self):
        i = Issue.add('test', 'test description', 'test', 'assignee')
        c = IssueComment.add(i.id, 'content', 'test')
        c = IssueComment.get(c.id)
        assert isinstance(c, IssueComment)
        assert c.issue_id == i.id
        assert c.content == 'content'
        assert c.author_id == 'test'

        c = IssueComment.add(i.id, 'content', 'test')
        cs = IssueComment.gets_by_issue_id(i.id)
        assert all([isinstance(t, IssueComment) for t in cs])
        assert len(cs) == 2
示例#8
0
文件: team.py 项目: leeccong/code
 def edit(self, request):
     if request.method == "POST":
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         team = self.team
         content = request.get_form_var("pull_request_comment", "").decode("utf-8")
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = team
         return dict(r=0, html=st("/widgets/issue/issue_comment.html", **locals()))
示例#9
0
文件: issue.py 项目: 000fan000/code
 def edit(self, request):
     if request.method == 'POST':
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         project = self.project
         content = request.get_form_var(
             'pull_request_comment', '').decode('utf-8')
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = project
         return dict(
             r=0, html=st('/widgets/issue/issue_comment.html', **locals()))
示例#10
0
文件: issue.py 项目: jackfrued/code-1
 def edit(self, request):
     if request.method == 'POST':
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         project = self.project
         content = request.get_form_var('pull_request_comment',
                                        '').decode('utf-8')
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = project
         return dict(r=0,
                     html=st('/widgets/issue/issue_comment.html',
                             **locals()))