Пример #1
0
class TroubleDocument(BaseDocument):
    def __init__(self, app):
        BaseDocument.__init__(self, app)
        self.manager = TroubleManager(self.app)

    def setID(self, clause=None, ids=None):
        self.clear_body()
        rows = self.manager.getTroubles(clause=clause)
        for row in rows:
            info = dict(row)
            crow = self.db.select_row(table='clients', clause=Eq('clientid', row.clientid))
            info['client'] = crow.client
            element = TroubleInfoElement(info)
            self.body.appendChild(element)
            self.body.appendChild(HR())

    def setStatusReport(self):
        counts = self.manager.getStatusCounts()
        hd = TextElement('h1', 'Status Report')
        self.body.appendChild(hd)
        for status, count in counts.items():
            st = TextElement('p', 'Status:  %s\t\t\tNumber: %d' % (status, count))
            self.body.appendChild(st)
            self.body.appendChild(BR())