Changeset 1582 for pykota/trunk/pykota

Show
Ignore:
Timestamp:
07/01/04 19:45:49 (20 years ago)
Author:
jalet
Message:

Added code to handle the description field for printers

Location:
pykota/trunk/pykota
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/reporter.py

    r1418 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.9  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.8  2004/03/24 15:15:24  jalet 
    2528# Began integration of Henrik Janhagen's work on quota-then-balance 
     
    7073         
    7174    def getPrinterTitle(self, printer) :      
    72         return _("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name) 
     75        return (_("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name)) + (" (%s)" % printer.Description) 
    7376         
    7477    def getPrinterGraceDelay(self, printer) :     
     
    100103        balance = float(entry.AccountBalance or 0.0) 
    101104        lifetimepaid = float(entry.LifeTimePaid or 0.0) 
    102          
     105         
    103106        #balance 
    104107        if entry.LimitBy and (entry.LimitBy.lower() == "balance") :     
  • pykota/trunk/pykota/storage.py

    r1523 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.56  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.55  2004/06/05 22:18:04  jalet 
    2528# Now catches some exceptions earlier. 
     
    317320        self.PricePerPage = None 
    318321        self.PricePerJob = None 
     322        self.Description = None 
    319323         
    320324    def __getattr__(self, name) :     
     
    353357            self.PricePerJob = float(priceperjob) 
    354358        self.parent.writePrinterPrices(self) 
     359         
     360    def setDescription(self, description = None) :     
     361        """Sets the printer's prices.""" 
     362        if description is None : 
     363            description = self.Description 
     364        else :     
     365            self.Description = str(description) 
     366        self.parent.writePrinterDescription(self) 
    355367         
    356368    def delete(self) :     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1534 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.71  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.70  2004/06/10 20:50:25  jalet 
    2528# Better log message 
     
    535538        """Extracts printer information given its name : returns first matching printer.""" 
    536539        printer = StoragePrinter(self, printername) 
    537         result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 
     540        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 
    538541        if result : 
    539542            fields = result[0][1]       # take only first matching printer, ignore the rest 
     
    543546            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    544547            printer.uniqueMember = fields.get("uniqueMember", []) 
     548            printer.Description = fields.get("description", [""])[0] 
    545549            printer.Exists = 1 
    546550        return printer     
     
    700704        printers = [] 
    701705        # see comment at the same place in pgstorage.py 
    702         result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 
     706        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 
    703707        if result : 
    704708            for (printerid, fields) in result : 
     
    709713                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    710714                printer.uniqueMember = fields.get("uniqueMember", []) 
     715                printer.Description = fields.get("description", [""])[0] 
    711716                printer.Exists = 1 
    712717                printers.append(printer) 
     
    895900                   "pykotaPricePerPage" : str(printer.PricePerPage), 
    896901                   "pykotaPricePerJob" : str(printer.PricePerJob), 
     902                 } 
     903        self.doModify(printer.ident, fields) 
     904         
     905    def writePrinterDescription(self, printer) :     
     906        """Write the printer's description back into the storage.""" 
     907        fields = { 
     908                   "description" : str(printer.Description), 
    897909                 } 
    898910        self.doModify(printer.ident, fields) 
  • pykota/trunk/pykota/storages/sql.py

    r1531 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.43  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.42  2004/06/08 17:44:43  jalet 
    2528# Payment now gets deleted when the user is deleted 
     
    115118            printer.ident = fields.get("id") 
    116119            printer.Name = fields.get("printername", printername) 
    117             printer.PricePerJob = fields.get("priceperjob") 
    118             printer.PricePerPage = fields.get("priceperpage") 
     120            printer.PricePerJob = fields.get("priceperjob") or 0.0 
     121            printer.PricePerPage = fields.get("priceperpage") or 0.0 
     122            printer.Description = fields.get("description") or "" 
    119123            printer.Exists = 1 
    120124        return printer     
     
    228232                    printer = StoragePrinter(self, record["printername"]) 
    229233                    printer.ident = record.get("id") 
    230                     printer.PricePerJob = record.get("priceperjob") 
    231                     printer.PricePerPage = record.get("priceperpage") 
     234                    printer.PricePerJob = record.get("priceperjob") or 0.0 
     235                    printer.PricePerPage = record.get("priceperpage") or 0.0 
     236                    printer.Description = record.get("description") or "" 
    232237                    printer.Exists = 1 
    233238                    printers.append(printer) 
     
    313318        self.doModify("UPDATE printers SET priceperpage=%s, priceperjob=%s WHERE id=%s" % (self.doQuote(printer.PricePerPage), self.doQuote(printer.PricePerJob), self.doQuote(printer.ident))) 
    314319         
     320    def writePrinterDescription(self, printer) :     
     321        """Write the printer's description back into the storage.""" 
     322        self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(printer.Description), self.doQuote(printer.ident))) 
     323         
    315324    def writeUserLimitBy(self, user, limitby) :     
    316325        """Sets the user's limiting factor.""" 
  • pykota/trunk/pykota/tool.py

    r1565 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.109  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.108  2004/06/24 23:09:30  jalet 
    2528# Also prints read size on last block 
     
    475478        if self.debug : 
    476479            self.logger.log_message(message, "debug") 
     480             
     481    def printError(self, message) :         
     482        """Sends a message to standard error.""" 
     483        sys.stderr.write("%s\n" % message) 
     484        sys.stderr.flush() 
    477485         
    478486    def clean(self) :