本文整理汇总了Python中trac.ticket.web_ui.TicketModule.rendered_changelog_entries方法的典型用法代码示例。如果您正苦于以下问题:Python TicketModule.rendered_changelog_entries方法的具体用法?Python TicketModule.rendered_changelog_entries怎么用?Python TicketModule.rendered_changelog_entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.web_ui.TicketModule
的用法示例。
在下文中一共展示了TicketModule.rendered_changelog_entries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_sheet_history
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import rendered_changelog_entries [as 别名]
def _create_sheet_history(self, req, context, data, book):
sheet = book.add_sheet(dgettext("messages", "Change History"))
writer = WorksheetWriter(sheet, req)
groups = data['groups']
headers = [header for header in data['headers']
if header['name'] not in ('id', 'time', 'changetime')]
headers[0:0] = [
{'name': 'id', 'label': dgettext("messages", "Ticket")},
{'name': 'time', 'label': dgettext("messages", "Time")},
{'name': 'author', 'label': dgettext("messages", "Author")},
{'name': 'comment', 'label': dgettext("messages", "Comment")},
]
writer.write_row(
(header['label'], 'thead', None, None)
for idx, header in enumerate(headers))
mod = TicketModule(self.env)
for result in chain(*[results for groupname, results in groups]):
id = result['id']
ticket = Ticket(self.env, id)
ticket_context = context('ticket', id)
values = ticket.values.copy()
changes = []
for change in mod.rendered_changelog_entries(req, ticket):
if change['permanent']:
changes.append(change)
for change in reversed(changes):
change['values'] = values
values = values.copy()
for name, field in change['fields'].iteritems():
if name in values:
values[name] = field['old']
changes[0:0] = [{'date': ticket.time_created, 'fields': {},
'values': values, 'cnum': None,
'comment': '', 'author': ticket['reporter']}]
for change in changes:
cells = []
for idx, header in enumerate(headers):
name = header['name']
if name == 'id':
value = id
elif name == 'time':
value = change.get('date', '')
elif name == 'comment':
value = change.get('comment', '')
elif name == 'author':
value = change.get('author', '')
else:
value = change['values'].get(name, '')
value, style, width, line = \
self._get_cell_data(name, value, req,
ticket_context, writer)
if name in change['fields']:
style = '%s:change' % style
cells.append((value, style, width, line))
writer.write_row(cells)
writer.set_col_widths()