當前位置: 首頁>>代碼示例>>Python>>正文


Python TicketModule.rendered_changelog_entries方法代碼示例

本文整理匯總了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()
開發者ID:nyuhuhuu,項目名稱:trachacks,代碼行數:64,代碼來源:ticket.py


注:本文中的trac.ticket.web_ui.TicketModule.rendered_changelog_entries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。