本文整理汇总了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
示例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()