Changeset 3568

Show
Ignore:
Timestamp:
03/04/13 05:52:27 (12 years ago)
Author:
jerome
Message:

Don't output reports anymore for printers without any print quota entry.

Location:
pykota/trunk/pykota/reporters
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/reporters/html.py

    r3561 r3568  
    3838            prefix = "User" 
    3939        for printer in self.printers : 
    40             phistoryurl = { "printername" : printer.Name, "history" : 1 } 
    41             self.report.append('<a href="%s?%s"><h2 class="printername">%s</h2></a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode(phistoryurl), self.getPrinterTitle(printer))) 
    42             self.report.append('<h3 class="printergracedelay">%s</h3>' % self.getPrinterGraceDelay(printer)) 
    43             (pjob, ppage) = self.getPrinterPrices(printer) 
    44             self.report.append('<h4 class="priceperjob">%s</h4>' % pjob) 
    45             self.report.append('<h4 class="priceperpage">%s</h4>' % ppage) 
    46             total = 0 
    47             totalmoney = 0.0 
    48             self.report.append('<table class="pykotatable" border="1">') 
    49             headers = self.getReportHeader().split() 
    50             headers.insert(1, "LimitBy") 
    51             self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
    52             oddeven = 0 
    53             for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) : 
    54                 oddeven += 1 
    55                 if oddeven % 2 : 
    56                     oddevenclass = "odd" 
    57                 else : 
    58                     oddevenclass = "even" 
    59                 (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, overcharge, warncount) = self.getQuota(entry, entrypquota) 
    60                 if datelimit : 
    61                     if datelimit == "DENY" : 
    62                         oddevenclass = "deny" 
     40            entries = getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) 
     41            if entries : 
     42                phistoryurl = { "printername" : printer.Name, "history" : 1 } 
     43                self.report.append('<a href="%s?%s"><h2 class="printername">%s</h2></a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode(phistoryurl), self.getPrinterTitle(printer))) 
     44                self.report.append('<h3 class="printergracedelay">%s</h3>' % self.getPrinterGraceDelay(printer)) 
     45                (pjob, ppage) = self.getPrinterPrices(printer) 
     46                self.report.append('<h4 class="priceperjob">%s</h4>' % pjob) 
     47                self.report.append('<h4 class="priceperpage">%s</h4>' % ppage) 
     48                total = 0 
     49                totalmoney = 0.0 
     50                self.report.append('<table class="pykotatable" border="1">') 
     51                headers = self.getReportHeader().split() 
     52                headers.insert(1, "LimitBy") 
     53                self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
     54                oddeven = 0 
     55                for (entry, entrypquota) in entries : 
     56                    oddeven += 1 
     57                    if oddeven % 2 : 
     58                        oddevenclass = "odd" 
    6359                    else : 
    64                         oddevenclass = "warn" 
    65                 if (not self.tool.config.getDisableHistory()) and (not self.isgroup) : 
    66                     name = '<a href="%s?username=%s&printername=%s&history=1">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), name, printer.Name, name) 
    67                 self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, overcharge, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid, warncount)]))) 
    68                 total += pages 
    69                 totalmoney += money 
     60                        oddevenclass = "even" 
     61                    (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, overcharge, warncount) = self.getQuota(entry, entrypquota) 
     62                    if datelimit : 
     63                        if datelimit == "DENY" : 
     64                            oddevenclass = "deny" 
     65                        else : 
     66                            oddevenclass = "warn" 
     67                    if (not self.tool.config.getDisableHistory()) and (not self.isgroup) : 
     68                        name = '<a href="%s?username=%s&printername=%s&history=1">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), name, printer.Name, name) 
     69                    self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, overcharge, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid, warncount)]))) 
     70                    total += pages 
     71                    totalmoney += money 
    7072 
    71             if total or totalmoney : 
    72                 (tpage, tmoney) = self.getTotals(total, totalmoney) 
    73                 self.report.append('<tr class="totals"><td colspan="8">&nbsp;</td><td align="right">%s</td><td align="right">%s</td><td>&nbsp;</td></tr>' % (tpage, tmoney)) 
    74             self.report.append('<tr class="realpagecounter"><td colspan="8">&nbsp;</td><td align="right">%s</td><td>&nbsp;</td></tr>' % self.getPrinterRealPageCounter(printer)) 
    75             self.report.append('</table>') 
     73                if total or totalmoney : 
     74                    (tpage, tmoney) = self.getTotals(total, totalmoney) 
     75                    self.report.append('<tr class="totals"><td colspan="8">&nbsp;</td><td align="right">%s</td><td align="right">%s</td><td>&nbsp;</td></tr>' % (tpage, tmoney)) 
     76                self.report.append('<tr class="realpagecounter"><td colspan="8">&nbsp;</td><td align="right">%s</td><td>&nbsp;</td></tr>' % self.getPrinterRealPageCounter(printer)) 
     77                self.report.append('</table>') 
    7678        if self.isgroup : 
    7779            self.report.append('<p class="warning">%s</p>' % _("Totals may be inaccurate if some users are members of several groups.")) 
  • pykota/trunk/pykota/reporters/text.py

    r3561 r3568  
    3535            prefix = "User" 
    3636        for printer in self.printers : 
    37             self.report.append(self.getPrinterTitle(printer)) 
    38             self.report.append(self.getPrinterGraceDelay(printer)) 
    39             (pjob, ppage) = self.getPrinterPrices(printer) 
    40             self.report.append(pjob) 
    41             self.report.append(ppage) 
     37            entries = getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) 
     38            if entries : 
     39                self.report.append(self.getPrinterTitle(printer)) 
     40                self.report.append(self.getPrinterGraceDelay(printer)) 
     41                (pjob, ppage) = self.getPrinterPrices(printer) 
     42                self.report.append(pjob) 
     43                self.report.append(ppage) 
    4244 
    43             total = 0 
    44             totalmoney = 0.0 
    45             header = self.getReportHeader() 
    46             self.report.append(header) 
    47             self.report.append('-' * len(header)) 
    48             for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) : 
    49                 (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, overcharge, warncount) = self.getQuota(entry, entrypquota) 
    50                 self.report.append("%-15.15s %s %5s %7i %7s %7s %10s %-10.10s %8i %10s %4s" % (name, reached, overcharge, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, warncount)) 
    51                 total += pages 
    52                 totalmoney += money 
     45                total = 0 
     46                totalmoney = 0.0 
     47                header = self.getReportHeader() 
     48                self.report.append(header) 
     49                self.report.append('-' * len(header)) 
     50                for (entry, entrypquota) in entries : 
     51                    (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, overcharge, warncount) = self.getQuota(entry, entrypquota) 
     52                    self.report.append("%-15.15s %s %5s %7i %7s %7s %10s %-10.10s %8i %10s %4s" % (name, reached, overcharge, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, warncount)) 
     53                    total += pages 
     54                    totalmoney += money 
    5355 
    54             if total or totalmoney : 
    55                 (tpage, tmoney) = self.getTotals(total, totalmoney) 
    56                 self.report.append((" " * 62) + tpage + tmoney) 
    57             self.report.append((" " * 63) + self.getPrinterRealPageCounter(printer)) 
    58             self.report.append("") 
     56                if total or totalmoney : 
     57                    (tpage, tmoney) = self.getTotals(total, totalmoney) 
     58                    self.report.append((" " * 62) + tpage + tmoney) 
     59                self.report.append((" " * 63) + self.getPrinterRealPageCounter(printer)) 
     60                self.report.append("") 
    5961        if self.isgroup : 
    6062            self.report.append(_("Totals may be inaccurate if some users are members of several groups."))