本文整理匯總了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()