Changeset 1203
- Timestamp:
- 11/23/03 20:01:37 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 12 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1200 r1203 24 24 # 25 25 # $Log$ 26 # Revision 1.13 2003/11/23 19:01:35 jalet 27 # Job price added to history 28 # 26 29 # Revision 1.12 2003/11/21 14:28:43 jalet 27 30 # More complete job history. … … 357 360 # update the quota for the current user on this printer 358 361 if printer.Exists : 362 jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 359 363 if jobsize : 360 364 userquota = thebackend.storage.getUserPQuota(user, printer) … … 363 367 364 368 # adds the current job to history 365 printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options)369 printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, jobprice, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options) 366 370 367 371 return retcode # return (retcode or gotSigTerm) shouldn't be needed -
pykota/trunk/initscripts/ldap/pykota.schema
r1200 r1203 163 163 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 164 164 165 # pykotaJobPrice 166 attributetype ( 1.3.6.1.4.1.16868.1.1.23 NAME 'pykotaJobPrice' 167 DESC 'Price of a particular job in the history, float' 168 EQUALITY caseIgnoreIA5Match 169 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 170 165 171 # 166 172 # PyKota Object Classes … … 201 207 DESC 'An entry in the job history for a printer' 202 208 MUST ( cn $ pykotaUserName $ pykotaPrinterName $ pykotaJobId ) 203 MAY ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykota FileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) )209 MAY ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) ) 204 210 205 211 # pykotaAccountBalance -
pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
r1200 r1203 20 20 -- 21 21 -- $Log$ 22 -- Revision 1.6 2003/11/23 19:01:36 jalet 23 -- Job price added to history 24 -- 22 25 -- Revision 1.5 2003/11/21 14:28:45 jalet 23 26 -- More complete job history. … … 111 114 pagecounter INT4 DEFAULT 0, 112 115 jobsize INT4, 116 jobprice FLOAT, 113 117 action TEXT, 114 118 filename TEXT, -
pykota/trunk/initscripts/postgresql/README.postgresql
r1200 r1203 69 69 This script adds some fields to the print job history, so that 70 70 more complete information will be known. The fields that 71 are added are : filename, title, copies and print command options.72 Also some indexes are created to speed things up.71 are added are : jobprice, filename, title, copies and print 72 command options. Also some indexes are created to speed things up. 73 73 74 74 What is below is for historical reasons only, real people don't use -
pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql
r1201 r1203 20 20 -- 21 21 -- $Log$ 22 -- Revision 1.2 2003/11/23 19:01:36 jalet 23 -- Job price added to history 24 -- 22 25 -- Revision 1.1 2003/11/21 14:29:14 jalet 23 26 -- Forgot to add this file... … … 39 42 -- Modify the old database schema 40 43 -- 44 ALTER TABLE jobhistory ADD COLUMN jobprice FLOAT; 41 45 ALTER TABLE jobhistory ADD COLUMN filename TEXT; 42 46 ALTER TABLE jobhistory ADD COLUMN title TEXT; -
pykota/trunk/NEWS
r1200 r1203 22 22 PyKota NEWS : 23 23 24 - 1.16alpha12 : 25 26 - Job price added to job history, to keep accounting correct 27 if a printer price per page or per job is modified and the 28 history is not reset : the history would have given a false 29 amount of money charged before the printer's prices were 30 modified, this addition solves the problem. 31 24 32 - 1.16alpha11 : 25 33 -
pykota/trunk/pykota/accounters/external.py
r1200 r1203 22 22 # 23 23 # $Log$ 24 # Revision 1.10 2003/11/23 19:01:36 jalet 25 # Job price added to history 26 # 24 27 # Revision 1.9 2003/11/21 14:28:45 jalet 25 28 # More complete job history. … … 107 110 108 111 # adds the current job to history 109 printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 112 jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 113 printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 110 114 111 115 self.endJob(printer, user) -
pykota/trunk/pykota/accounters/stupid.py
r1200 r1203 22 22 # 23 23 # $Log$ 24 # Revision 1.8 2003/11/23 19:01:37 jalet 25 # Job price added to history 26 # 24 27 # Revision 1.7 2003/11/21 14:28:46 jalet 25 28 # More complete job history. … … 109 112 110 113 # adds the current job to history 111 printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 114 jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 115 printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 112 116 113 117 return action -
pykota/trunk/pykota/storage.py
r1200 r1203 22 22 # 23 23 # $Log$ 24 # Revision 1.27 2003/11/23 19:01:36 jalet 25 # Job price added to history 26 # 24 27 # Revision 1.26 2003/11/21 14:28:45 jalet 25 28 # More complete job history. … … 214 217 self.LastJob = None 215 218 216 def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :219 def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 217 220 """Adds a job to the printer's history.""" 218 self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, filename, title, copies, options)221 self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) 219 222 # TODO : update LastJob object ? Probably not needed. 220 223 … … 314 317 self.JobAction = None 315 318 self.JobDate = None 319 self.JobPrice = None 320 self.JobFileName = None 321 self.JobTitle = None 322 self.JobCopies = None 323 self.JobOptions = None 316 324 317 325 def setSize(self, jobsize) : 318 326 """Sets the last job's size.""" 319 self.parent.writeLastJobSize(self, jobsize) 327 jobprice = (float(self.Printer.PricePerPage or 0.0) * jobsize) + float(self.Printer.PricePerJob or 0.0) 328 self.parent.writeLastJobSize(self, jobsize, jobprice) 320 329 self.JobSize = jobsize 330 self.JobPrice = jobprice 321 331 322 332 class BaseStorage : -
pykota/trunk/pykota/storages/ldapstorage.py
r1200 r1203 22 22 # 23 23 # $Log$ 24 # Revision 1.37 2003/11/23 19:01:37 jalet 25 # Job price added to history 26 # 24 27 # Revision 1.36 2003/11/21 14:28:46 jalet 25 28 # More complete job history. … … 407 410 lastjob.lastjobident = result[0][0] 408 411 lastjobident = result[0][1]["pykotaLastJobIdent"][0] 409 result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", " createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)412 result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 410 413 if result : 411 414 fields = result[0][1] … … 415 418 lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter")[0] or 0) 416 419 lastjob.JobSize = int(fields.get("pykotaJobSize", [0])[0]) 420 lastjob.JobPrice = float(fields.get("pykotaJobPrice", [0.0])[0]) 417 421 lastjob.JobAction = fields.get("pykotaAction")[0] 422 lastjob.JobFileName = fields.get("pykotaFileName")[0] 423 lastjob.JobTitle = fields.get("pykotaTitle")[0] 424 lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 425 lastjob.JobOptions = fields.get("pykotaOptions")[0] 418 426 date = fields.get("createTimestamp")[0] 419 427 year = int(date[:4]) … … 686 694 return self.doModify(user.idbalance, fields) 687 695 688 def writeLastJobSize(self, lastjob, jobsize ) :696 def writeLastJobSize(self, lastjob, jobsize, jobprice) : 689 697 """Sets the last job's size permanently.""" 690 698 fields = { 691 699 "pykotaJobSize" : str(jobsize), 700 "pykotaJobPrice" : str(jobprice), 692 701 } 693 702 self.doModify(lastjob.ident, fields) 694 703 695 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :704 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 696 705 """Adds a job in a printer's history.""" 697 706 if (not self.disablehistory) or (not printer.LastJob.Exists) : … … 716 725 if (not self.disablehistory) or (not printer.LastJob.Exists) : 717 726 if jobsize is not None : 718 fields.update({ "pykotaJobSize" : str(jobsize) })727 fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) }) 719 728 self.doAdd(dn, fields) 720 729 else : 721 730 # here we explicitly want to reset jobsize to 'None' if needed 722 fields.update({ "pykotaJobSize" : str(jobsize) })731 fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) }) 723 732 self.doModify(dn, fields) 724 733 -
pykota/trunk/pykota/storages/pgstorage.py
r1200 r1203 22 22 # 23 23 # $Log$ 24 # Revision 1.23 2003/11/23 19:01:37 jalet 25 # Job price added to history 26 # 24 27 # Revision 1.22 2003/11/21 14:28:46 jalet 25 28 # More complete job history. … … 282 285 """Extracts a printer's last job information.""" 283 286 lastjob = StorageLastJob(self, printer) 284 result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, job date FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))287 result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, jobdate FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident)) 285 288 if result : 286 289 fields = result[0] … … 290 293 lastjob.PrinterPageCounter = fields.get("pagecounter") 291 294 lastjob.JobSize = fields.get("jobsize") 295 lastjob.JobPrice = fields.get("jobprice") 292 296 lastjob.JobAction = fields.get("action") 297 lastjob.JobFileName = fields.get("filename") 298 lastjob.JobTitle = fields.get("title") 299 lastjob.JobCopies = fields.get("copies") 300 lastjob.JobOptions = fields.get("options") 293 301 lastjob.JobDate = fields.get("jobdate") 294 302 lastjob.Exists = 1 … … 446 454 self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident))) 447 455 448 def writeLastJobSize(self, lastjob, jobsize ) :456 def writeLastJobSize(self, lastjob, jobsize, jobprice) : 449 457 """Sets the last job's size permanently.""" 450 self.doModify("UPDATE jobhistory SET jobsize=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(lastjob.ident)))451 452 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :458 self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident))) 459 460 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 453 461 """Adds a job in a printer's history.""" 454 462 if (not self.disablehistory) or (not printer.LastJob.Exists) : 455 463 if jobsize is not None : 456 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))464 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options))) 457 465 else : 458 466 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options))) 459 467 else : 460 468 # here we explicitly want to reset jobsize to NULL if needed 461 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, job date=now() WHERE id=%s;" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(printer.LastJob.ident)))469 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, jobdate=now() WHERE id=%s;" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(printer.LastJob.ident))) 462 470 463 471 def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : -
pykota/trunk/pykota/version.py
r1200 r1203 22 22 # 23 23 24 __version__ = "1.16alpha1 1_unofficial"24 __version__ = "1.16alpha12_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""