当前位置: 首页>>代码示例>>Python>>正文


Python Ticket.delete方法代码示例

本文整理汇总了Python中trac.ticket.Ticket.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.delete方法的具体用法?Python Ticket.delete怎么用?Python Ticket.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.Ticket的用法示例。


在下文中一共展示了Ticket.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: move

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import delete [as 别名]
    def move(self, ticket_id, author, env, delete=False):
        """
        move a ticket to another environment
        
        env: environment to move to
        """
        tables = {"attachment": "id", "ticket_change": "ticket"}

        # open the environment if it is a string
        if isinstance(env, basestring):
            base_path, _project = os.path.split(self.env.path)
            env = open_environment(os.path.join(base_path, env), use_cache=True)

        # get the old ticket
        old_ticket = Ticket(self.env, ticket_id)

        # make a new ticket from the old ticket values
        new_ticket = Ticket(env)
        new_ticket.values = old_ticket.values.copy()
        new_ticket.insert(when=old_ticket.time_created)

        # copy the changelog and attachment DBs
        for table, _id in tables.items():
            for row in get_all_dict(self.env, "SELECT * FROM %s WHERE %s=%%s" % (table, _id), str(ticket_id)):
                row[_id] = new_ticket.id
                insert_row_from_dict(env, table, row)

        # copy the attachments
        src_attachment_dir = os.path.join(self.env.path, "attachments", "ticket", str(ticket_id))
        if os.path.exists(src_attachment_dir):
            dest_attachment_dir = os.path.join(env.path, "attachments", "ticket")
            if not os.path.exists(dest_attachment_dir):
                os.makedirs(dest_attachment_dir)
            dest_attachment_dir = os.path.join(dest_attachment_dir, str(new_ticket.id))
            shutil.copytree(src_attachment_dir, dest_attachment_dir)

        # note the previous location on the new ticket
        new_ticket.save_changes(author, "moved from %s" % self.env.abs_href("ticket", ticket_id))

        # location of new ticket
        new_location = env.abs_href.ticket(new_ticket.id)

        if delete:
            old_ticket.delete()
        else:
            # close old ticket and point to new one
            old_ticket["status"] = u"closed"
            old_ticket["resolution"] = u"moved"
            old_ticket.save_changes(author, u"moved to %s" % new_location)

        if env.config["trac"].get("base_url"):
            return new_location
        else:
            return None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:56,代码来源:ticketmover.py

示例2: _delete_tickets_from_milestone

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import delete [as 别名]
	def _delete_tickets_from_milestone(self, db, milestone):
		tickets = get_tickets_for_milestone(self.env, db, milestone)
		for t in tickets:
			id = t['id']
			ticket = Ticket(self.env, tkt_id=id, db=db)
			ticket.delete()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:qatracker.py


注:本文中的trac.ticket.Ticket.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。