Example #1
0
    def filter_stream(self, req, method, filename, stream, data):
        """Return a filtered Genshi event stream, or the original unfiltered
        stream if no match.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.

        See the Genshi documentation for more information.
        """
        if filename == 'ticket.html':
            ticket = data['ticket']
            if ticket.exists:
                if req.perm.has_permission('SENSITIVE_VIEW'):
                    qry = DBSession().query(CustomerRequest)
                    if not qry.get(ticket.values.get('customerrequest')).active:
                        div = tag.div(
                            tag.div(
                                tag.strong(u'Heads up! '),
                                tag.span(u'This ticket is assigned to an inactive customer request.',),
                                class_="alert alert-info"),
                            id='inactive_cr_ticket')
                        return stream | Transformer("//div[@id='ticket']").before(div)
        return stream
Example #2
0
    def TicketModule_grouped_changelog_entries(self, ticket, db, when=None):
        ret = _grouped_changelog_entries(self, ticket, db, when)
        for item in ret:
            try:
                cr = item['fields']['customerrequest']
                qry = DBSession().query(CustomerRequest)
                old_cr = qry.get(cr['old'])
                new_cr = qry.get(cr['new'])
                cr['old'] = old_cr.name if old_cr else cr['old']
                cr['new'] = new_cr.name if new_cr else cr['new']
            except KeyError:
                pass

            yield item