Changeset 1582 for pykota/trunk/pykota
- Timestamp:
- 07/01/04 19:45:49 (20 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/reporter.py
r1418 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.9 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.8 2004/03/24 15:15:24 jalet 25 28 # Began integration of Henrik Janhagen's work on quota-then-balance … … 70 73 71 74 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) 73 76 74 77 def getPrinterGraceDelay(self, printer) : … … 100 103 balance = float(entry.AccountBalance or 0.0) 101 104 lifetimepaid = float(entry.LifeTimePaid or 0.0) 102 105 103 106 #balance 104 107 if entry.LimitBy and (entry.LimitBy.lower() == "balance") : -
pykota/trunk/pykota/storage.py
r1523 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.56 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.55 2004/06/05 22:18:04 jalet 25 28 # Now catches some exceptions earlier. … … 317 320 self.PricePerPage = None 318 321 self.PricePerJob = None 322 self.Description = None 319 323 320 324 def __getattr__(self, name) : … … 353 357 self.PricePerJob = float(priceperjob) 354 358 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) 355 367 356 368 def delete(self) : -
pykota/trunk/pykota/storages/ldapstorage.py
r1534 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.71 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.70 2004/06/10 20:50:25 jalet 25 28 # Better log message … … 535 538 """Extracts printer information given its name : returns first matching printer.""" 536 539 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"]) 538 541 if result : 539 542 fields = result[0][1] # take only first matching printer, ignore the rest … … 543 546 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 544 547 printer.uniqueMember = fields.get("uniqueMember", []) 548 printer.Description = fields.get("description", [""])[0] 545 549 printer.Exists = 1 546 550 return printer … … 700 704 printers = [] 701 705 # 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"]) 703 707 if result : 704 708 for (printerid, fields) in result : … … 709 713 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 710 714 printer.uniqueMember = fields.get("uniqueMember", []) 715 printer.Description = fields.get("description", [""])[0] 711 716 printer.Exists = 1 712 717 printers.append(printer) … … 895 900 "pykotaPricePerPage" : str(printer.PricePerPage), 896 901 "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), 897 909 } 898 910 self.doModify(printer.ident, fields) -
pykota/trunk/pykota/storages/sql.py
r1531 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.43 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.42 2004/06/08 17:44:43 jalet 25 28 # Payment now gets deleted when the user is deleted … … 115 118 printer.ident = fields.get("id") 116 119 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 "" 119 123 printer.Exists = 1 120 124 return printer … … 228 232 printer = StoragePrinter(self, record["printername"]) 229 233 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 "" 232 237 printer.Exists = 1 233 238 printers.append(printer) … … 313 318 self.doModify("UPDATE printers SET priceperpage=%s, priceperjob=%s WHERE id=%s" % (self.doQuote(printer.PricePerPage), self.doQuote(printer.PricePerJob), self.doQuote(printer.ident))) 314 319 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 315 324 def writeUserLimitBy(self, user, limitby) : 316 325 """Sets the user's limiting factor.""" -
pykota/trunk/pykota/tool.py
r1565 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.109 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.108 2004/06/24 23:09:30 jalet 25 28 # Also prints read size on last block … … 475 478 if self.debug : 476 479 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() 477 485 478 486 def clean(self) :