示例#1
0
文件: ticket.py 项目: leeccong/code
 def add(cls, ticket_id, content, path, position,
         old, new, from_ref, author, new_path=None):
     # FIXME: mysql里的content是废的啊,是历史原因么?
     line_mark = str(old) + '|' + str(new)
     id = store.execute("insert into codedouban_ticket_codereview "
                        "(ticket_id, content, path, position, line_mark, "
                        "from_ref, author, new_path) "
                        "values (%s, %s, %s, %s, %s, %s, %s, %s)",
                        (ticket_id, content, path, position, line_mark,
                         from_ref, author, new_path))
     if not id:
         store.rollback()
         raise Exception("Unable to add")
     store.commit()
     bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % id, content)
     comment = cls.get(id)
     ticket = Ticket.get(ticket_id)
     # TODO: 重构feed之后取消signal发送
     codereview_signal.send(comment, content=content,
                            ticket=Ticket.get(ticket_id),
                            author=author, comment=comment)
     dispatch('codereview', data={
              'comment': comment,
              'ticket': ticket,
              'sender': author,
              })
     return comment
示例#2
0
 def add(cls, target_id, from_sha, to_sha, old_path, new_path, from_oid,
         to_oid, old_linenum, new_linenum, author, content):
     # TODO: dispatch 放到 view 里
     from vilya.models.ticket import Ticket
     from vilya.libs.signals import codereview_signal
     from dispatches import dispatch
     comment = super(PullLineComment,
                     cls).add(target_id, from_sha, to_sha, old_path,
                              new_path, from_oid, to_oid, old_linenum,
                              new_linenum, author, content)
     ticket = Ticket.get(target_id)
     # TODO: 重构feed之后取消signal发送
     if ticket:
         codereview_signal.send(comment,
                                content=content,
                                ticket=ticket,
                                author=author,
                                comment=comment)
         dispatch('codereview',
                  data={
                      'comment': comment,
                      'ticket': ticket,
                      'sender': author,
                  })
     return comment
示例#3
0
文件: nticket.py 项目: leeccong/code
 def after_create(self, extra_args):
     from models.ticket import Ticket
     comment = self
     TicketNode.add_comment(comment)
     content = extra_args
     bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content)
     ticket = Ticket.get(self.ticket_id)
     # TODO: 将Feed全部迁移到新的系统后,取消signal发送
     codereview_signal.send(comment,
                            content=content,
                            ticket=ticket,
                            author=self.author,
                            comment=comment)
     dispatch('codereview', data={
         'comment': comment,
         'ticket': ticket,
         'sender': self.author,
     })
示例#4
0
 def after_create(self, extra_args):
     from vilya.models.ticket import Ticket
     comment = self
     TicketNode.add_comment(comment)
     content = extra_args
     bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content)
     ticket = Ticket.get(self.ticket_id)
     # TODO: 将Feed全部迁移到新的系统后,取消signal发送
     codereview_signal.send(comment,
                            content=content,
                            ticket=ticket,
                            author=self.author,
                            comment=comment)
     dispatch('codereview',
              data={
                  'comment': comment,
                  'ticket': ticket,
                  'sender': self.author,
              })
示例#5
0
 def add(cls, target_id, from_sha, to_sha,
         old_path, new_path, from_oid, to_oid, old_linenum, new_linenum,
         author, content):
     # TODO: dispatch 放到 view 里
     from vilya.models.ticket import Ticket
     from vilya.libs.signals import codereview_signal
     from dispatches import dispatch
     comment = super(PullLineComment, cls).add(
         target_id, from_sha, to_sha, old_path, new_path, from_oid,
         to_oid, old_linenum, new_linenum, author, content)
     ticket = Ticket.get(target_id)
     # TODO: 重构feed之后取消signal发送
     if ticket:
         codereview_signal.send(comment, content=content,
                                ticket=ticket,
                                author=author, comment=comment)
         dispatch('codereview', data={
                  'comment': comment,
                  'ticket': ticket,
                  'sender': author,
                  })
     return comment
示例#6
0
 def add(cls,
         ticket_id,
         content,
         path,
         position,
         old,
         new,
         from_ref,
         author,
         new_path=None):
     # FIXME: mysql里的content是废的啊,是历史原因么?
     line_mark = str(old) + '|' + str(new)
     id = store.execute(
         "insert into codedouban_ticket_codereview "
         "(ticket_id, content, path, position, line_mark, "
         "from_ref, author, new_path) "
         "values (%s, %s, %s, %s, %s, %s, %s, %s)",
         (ticket_id, content, path, position, line_mark, from_ref, author,
          new_path))
     if not id:
         store.rollback()
         raise Exception("Unable to add")
     store.commit()
     bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % id, content)
     comment = cls.get(id)
     ticket = Ticket.get(ticket_id)
     # TODO: 重构feed之后取消signal发送
     codereview_signal.send(comment,
                            content=content,
                            ticket=Ticket.get(ticket_id),
                            author=author,
                            comment=comment)
     dispatch('codereview',
              data={
                  'comment': comment,
                  'ticket': ticket,
                  'sender': author,
              })
     return comment