Changeset 1251

Show
Ignore:
Timestamp:
01/06/04 16:51:46 (21 years ago)
Author:
jalet
Message:

Code factorization

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

Legend:

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

    r1240 r1251  
    2222# 
    2323# $Log$ 
     24# Revision 1.4  2004/01/06 15:51:46  jalet 
     25# Code factorization 
     26# 
    2427# Revision 1.3  2003/12/27 16:49:25  uid67467 
    2528# Should be ok now. 
     
    4043        """Produces a simple HTML report.""" 
    4144        self.report = [] 
     45        if self.isgroup : 
     46            prefix = "Group" 
     47        else :     
     48            prefix = "User" 
    4249        for printer in self.printers : 
    4350            self.report.append('<h2 class="printername">%s</h2>' % self.getPrinterTitle(printer)) 
     
    5360            self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
    5461            oddeven = 0 
    55             if self.isgroup : 
    56                 for (group, grouppquota) in self.tool.storage.getPrinterGroupsAndQuotas(printer, self.ugnames) : 
    57                     oddeven += 1 
    58                     if oddeven % 2 : 
    59                         oddevenclass = "odd" 
     62            for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) : 
     63                oddeven += 1 
     64                if oddeven % 2 : 
     65                    oddevenclass = "odd" 
     66                else :     
     67                    oddevenclass = "even" 
     68                (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(entry, entrypquota) 
     69                if datelimit : 
     70                    if datelimit == "DENY" : 
     71                        oddevenclass = "deny" 
    6072                    else :     
    61                         oddevenclass = "even" 
    62                     (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(group, grouppquota) 
    63                     self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)]))) 
    64                     total += pages 
    65                     totalmoney += money 
    66             else : 
    67                 # default is user quota report 
    68                 for (user, userpquota) in self.tool.storage.getPrinterUsersAndQuotas(printer, self.ugnames) : 
    69                     oddeven += 1 
    70                     if oddeven % 2 : 
    71                         oddevenclass = "odd" 
    72                     else :     
    73                         oddevenclass = "even" 
    74                     (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(user, userpquota) 
    75                     self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)]))) 
    76                     total += pages 
    77                     totalmoney += money 
     73                        oddevenclass = "warn" 
     74                self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)]))) 
     75                total += pages 
     76                totalmoney += money 
     77                 
    7878            if total or totalmoney :         
    7979                (tpage, tmoney) = self.getTotals(total, totalmoney) 
  • pykota/trunk/pykota/reporters/text.py

    r1240 r1251  
    2222# 
    2323# $Log$ 
     24# Revision 1.8  2004/01/06 15:51:46  jalet 
     25# Code factorization 
     26# 
    2427# Revision 1.7  2003/12/27 16:49:25  uid67467 
    2528# Should be ok now. 
     
    5558        """Produces a simple text report.""" 
    5659        self.report = [] 
     60        if self.isgroup : 
     61            prefix = "Group" 
     62        else :     
     63            prefix = "User" 
    5764        for printer in self.printers : 
    5865            self.report.append(self.getPrinterTitle(printer)) 
     
    6471            total = 0 
    6572            totalmoney = 0.0 
    66             if self.isgroup : 
    67                 header = self.getReportHeader() 
    68                 self.report.append(header) 
    69                 self.report.append('-' * len(header)) 
    70                 for (group, grouppquota) in self.tool.storage.getPrinterGroupsAndQuotas(printer, self.ugnames) : 
    71                     (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(group, grouppquota) 
    72                     self.report.append("%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid)) 
    73                     total += pages 
    74                     totalmoney += money 
    75             else : 
    76                 # default is user quota report 
    77                 header = self.getReportHeader() 
    78                 self.report.append(header) 
    79                 self.report.append('-' * len(header)) 
    80                 for (user, userpquota) in self.tool.storage.getPrinterUsersAndQuotas(printer, self.ugnames) : 
    81                     (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(user, userpquota) 
    82                     self.report.append("%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid)) 
    83                     total += pages 
    84                     totalmoney += money 
     73            header = self.getReportHeader() 
     74            self.report.append(header) 
     75            self.report.append('-' * len(header)) 
     76            for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) : 
     77                (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(entry, entrypquota) 
     78                self.report.append("%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid)) 
     79                total += pages 
     80                totalmoney += money 
     81                 
    8582            if total or totalmoney :         
    8683                (tpage, tmoney) = self.getTotals(total, totalmoney)