Index: /pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/pgstorage.py (revision 1327)
+++ /pykota/trunk/pykota/storages/pgstorage.py (revision 1520)
@@ -22,4 +22,10 @@
 #
 # $Log$
+# Revision 1.36  2004/06/03 23:14:11  jalet
+# Now stores the job's size in bytes in the database.
+# Preliminary work on payments storage : database schemas are OK now,
+# but no code to store payments yet.
+# Removed schema picture, not relevant anymore.
+#
 # Revision 1.35  2004/02/02 22:44:16  jalet
 # Preliminary work on Relationnal Database Independance via DB-API 2.0
@@ -223,4 +229,6 @@
         elif type(field) == type(0) :    
             typ = "int"
+        elif type(field) == type(0L) :    
+            typ = "int"
         else :    
             typ = "text"
Index: /pykota/trunk/pykota/storages/sql.py
===================================================================
--- /pykota/trunk/pykota/storages/sql.py (revision 1502)
+++ /pykota/trunk/pykota/storages/sql.py (revision 1520)
@@ -22,4 +22,10 @@
 #
 # $Log$
+# Revision 1.40  2004/06/03 23:14:11  jalet
+# Now stores the job's size in bytes in the database.
+# Preliminary work on payments storage : database schemas are OK now,
+# but no code to store payments yet.
+# Removed schema picture, not relevant anymore.
+#
 # Revision 1.39  2004/05/26 14:50:12  jalet
 # First try at saving the job-originating-hostname in the database
@@ -162,4 +168,5 @@
             lastjob.JobDate = fields.get("jobdate")
             lastjob.JobHostName = fields.get("hostname")
+            lastjob.JobSizeBytes = fields.get("jobsizebytes")
             lastjob.Exists = 1
         return lastjob
@@ -339,14 +346,14 @@
         self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident)))
         
-    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None) :    
+    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) :    
         """Adds a job in a printer's history."""
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
-                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname) VALUES (%s, %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), self.doQuote(clienthost)))
+                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname, jobsizebytes) VALUES (%s, %s, %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), self.doQuote(clienthost), self.doQuote(jobsizebytes)))
             else :    
-                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname) 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(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost)))
+                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname, jobsizebytes) 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(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes)))
         else :        
             # here we explicitly want to reset jobsize to NULL if needed
-            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, hostname=%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(clienthost), self.doQuote(printer.LastJob.ident)))
+            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, hostname=%s, jobsizebytes=%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(clienthost), self.doQuote(jobsizebytes), self.doQuote(printer.LastJob.ident)))
             
     def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) :
@@ -406,4 +413,5 @@
                 job.JobDate = fields.get("jobdate")
                 job.JobHostName = fields.get("hostname")
+                job.JobSizeBytes = fields.get("jobsizebytes")
                 job.UserName = fields.get("username")
                 job.PrinterName = fields.get("printername")
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 1510)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 1520)
@@ -22,4 +22,10 @@
 #
 # $Log$
+# Revision 1.67  2004/06/03 23:14:10  jalet
+# Now stores the job's size in bytes in the database.
+# Preliminary work on payments storage : database schemas are OK now,
+# but no code to store payments yet.
+# Removed schema picture, not relevant anymore.
+#
 # Revision 1.66  2004/05/28 20:56:45  jalet
 # Extended syntax for LDAP specific newuser and newgroup directives. Untested.
@@ -603,5 +609,5 @@
             lastjob.lastjobident = result[0][0]
             lastjobident = result[0][1]["pykotaLastJobIdent"][0]
-            result = self.doSearch("objectClass=pykotaJob", ["pykotaHostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)
+            result = self.doSearch("objectClass=pykotaJob", ["pykotaJobSizeBytes", "pykotaHostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)
             if result :
                 fields = result[0][1]
@@ -618,4 +624,5 @@
                 lastjob.JobOptions = fields.get("pykotaOptions", [""])[0]
                 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0]
+                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
                 date = fields.get("createTimestamp", ["19700101000000"])[0]
                 year = int(date[:4])
@@ -945,5 +952,5 @@
         self.doModify(lastjob.ident, fields)         
         
-    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None) :
+    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) :
         """Adds a job in a printer's history."""
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
@@ -966,4 +973,5 @@
                    "pykotaOptions" : str(options), 
                    "pykotaHostName" : str(clienthost), 
+                   "pykotaJobSizeBytes" : str(jobsizebytes),
                  }
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
@@ -1046,5 +1054,5 @@
             where = precond
         jobs = []    
-        result = self.doSearch(where, fields=["pykotaHostName", "pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"])
+        result = self.doSearch(where, fields=["pykotaJobSizeBytes", "pykotaHostName", "pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"])
         if result :
             for (ident, fields) in result :
@@ -1061,4 +1069,5 @@
                 job.JobOptions = fields.get("pykotaOptions", [""])[0]
                 job.JobHostName = fields.get("pykotaHostName", [""])[0]
+                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
                 date = fields.get("createTimestamp", ["19700101000000"])[0]
                 year = int(date[:4])
Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 1502)
+++ /pykota/trunk/pykota/storage.py (revision 1520)
@@ -22,4 +22,10 @@
 #
 # $Log$
+# Revision 1.53  2004/06/03 23:14:10  jalet
+# Now stores the job's size in bytes in the database.
+# Preliminary work on payments storage : database schemas are OK now,
+# but no code to store payments yet.
+# Removed schema picture, not relevant anymore.
+#
 # Revision 1.52  2004/05/26 14:49:57  jalet
 # First try at saving the job-originating-hostname in the database
@@ -303,7 +309,7 @@
             raise AttributeError, name
             
-    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None) :
+    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) :
         """Adds a job to the printer's history."""
-        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, clienthost)
+        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, clienthost, jobsizebytes)
         # TODO : update LastJob object ? Probably not needed.
         
@@ -449,4 +455,5 @@
         self.JobId = None
         self.PrinterPageCounter = None
+        self.JobSizeBytes = None
         self.JobSize = None
         self.JobAction = None
Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 1519)
+++ /pykota/trunk/bin/cupspykota (revision 1520)
@@ -24,4 +24,10 @@
 #
 # $Log$
+# Revision 1.60  2004/06/03 23:14:08  jalet
+# Now stores the job's size in bytes in the database.
+# Preliminary work on payments storage : database schemas are OK now,
+# but no code to store payments yet.
+# Removed schema picture, not relevant anymore.
+#
 # Revision 1.59  2004/06/03 22:12:53  jalet
 # Now denies empty jobs
@@ -403,5 +409,5 @@
             
             # adds the current job to history    
-            printer.addJobToHistory(self.jobid, user, self.accounter.getLastPageCounter(), action, jobsize, jobprice, self.preserveinputfile, self.title, self.copies, self.options, clienthost)
+            printer.addJobToHistory(self.jobid, user, self.accounter.getLastPageCounter(), action, jobsize, jobprice, self.preserveinputfile, self.title, self.copies, self.options, clienthost, self.jobSizeBytes)
             self.logdebug("Job added to history.")
             
Index: /pykota/trunk/initscripts/ldap/pykota.schema
===================================================================
--- /pykota/trunk/initscripts/ldap/pykota.schema (revision 1480)
+++ /pykota/trunk/initscripts/ldap/pykota.schema (revision 1520)
@@ -175,4 +175,16 @@
         SUBSTR caseIgnoreSubstringsMatch
         SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )
+        
+# pykotaJobSizeBytes
+attributetype ( 1.3.6.1.4.1.16868.1.1.25 NAME 'pykotaJobSizeBytes'
+        DESC 'Current job size in number of bytes in the history'
+        EQUALITY integerMatch
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+# pykotaPayments
+attributetype ( 1.3.6.1.4.1.16868.1.1.26 NAME 'pykotaPayments'
+        DESC 'Stores all payments made by an user, encoded to store both date and amount'
+        EQUALITY caseExactIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
 
 #        
@@ -214,10 +226,10 @@
         DESC 'An entry in the job history for a printer'
         MUST ( cn $ pykotaUserName $ pykotaPrinterName $ pykotaJobId )
-        MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions $ pykotaHostName ) )
+        MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions $ pykotaHostName $ pykotaJobSizeBytes ) )
         
 # pykotaAccountBalance
 objectclass ( 1.3.6.1.4.1.16868.1.2.7 NAME 'pykotaAccountBalance' SUP top AUXILIARY
         DESC 'PyKota User account balance'
-        MAY  ( pykotaUserName $ pykotaBalance $ pykotaLifeTimePaid ) )
+        MAY  ( pykotaUserName $ pykotaBalance $ pykotaLifeTimePaid $ pykotaPayments ) )
         
 # pykotaLastJob        
Index: /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1473)
+++ /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1520)
@@ -20,4 +20,10 @@
 --
 -- $Log$
+-- Revision 1.10  2004/06/03 23:14:09  jalet
+-- Now stores the job's size in bytes in the database.
+-- Preliminary work on payments storage : database schemas are OK now,
+-- but no code to store payments yet.
+-- Removed schema picture, not relevant anymore.
+--
 -- Revision 1.9  2004/05/13 11:15:29  jalet
 -- Added hostname field in job history
@@ -121,6 +127,6 @@
                         userid INT4,
                         printerid INT4,
-                        hostname TEXT,
                         pagecounter INT4 DEFAULT 0,
+                        jobsizebytes INT8,
                         jobsize INT4,
                         jobprice FLOAT,
@@ -130,8 +136,10 @@
                         copies INT4,
                         options TEXT,
+                        hostname TEXT,
                         jobdate TIMESTAMP DEFAULT now(),
                         CONSTRAINT checkUserPQuota FOREIGN KEY (userid, printerid) REFERENCES userpquota(userid, printerid));
 CREATE INDEX jobhistory_p_id_ix ON jobhistory (printerid);
 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate);
+CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname);
                         
 --
@@ -159,13 +167,21 @@
                            printerid INT4 REFERENCES printers(id),
                            PRIMARY KEY (groupid, printerid));
+--
+-- Create the table for payments
+-- 
+CREATE TABLE payments (id SERIAL PRIMARY KEY NOT NULL,
+                       userid INT4 REFERENCES users(id),
+                       amount FLOAT,
+                       date TIMESTAMP DEFAULT now());
+CREATE INDEX payments_date_ix ON payments (date);
 
 --                        
 -- Set some ACLs                        
 --
-REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory FROM public;                        
-REVOKE ALL ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq FROM public;
+REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory, payments FROM public;                        
+REVOKE ALL ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq, payments_id_seq FROM public;
 
-GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory TO pykotaadmin;
-GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq TO pykotaadmin;
-GRANT SELECT ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory TO pykotauser;
+GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory, payments TO pykotaadmin;
+GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq, payments_id_seq TO pykotaadmin;
+GRANT SELECT ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory, payments TO pykotauser;
 
Index: /pykota/trunk/initscripts/postgresql/upgrade-to-1.19.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/upgrade-to-1.19.sql (revision 1473)
+++ /pykota/trunk/initscripts/postgresql/upgrade-to-1.19.sql (revision 1520)
@@ -20,4 +20,10 @@
 --
 -- $Log$
+-- Revision 1.2  2004/06/03 23:14:10  jalet
+-- Now stores the job's size in bytes in the database.
+-- Preliminary work on payments storage : database schemas are OK now,
+-- but no code to store payments yet.
+-- Removed schema picture, not relevant anymore.
+--
 -- Revision 1.1  2004/05/13 11:15:29  jalet
 -- Added hostname field in job history
@@ -39,4 +45,17 @@
 -- Modify the old database schema
 --
+ALTER TABLE jobhistory ADD COLUMN jobsizebytes INT8;
 ALTER TABLE jobhistory ADD COLUMN hostname TEXT;
+CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname);
 
+CREATE TABLE payments (id SERIAL PRIMARY KEY NOT NULL,
+                       userid INT4 REFERENCES users(id),
+                       amount FLOAT,
+                       date TIMESTAMP DEFAULT now());
+CREATE INDEX payments_date_ix ON payments (date);
+
+REVOKE ALL ON payments FROM public;                        
+REVOKE ALL ON payments_id_seq FROM public;
+GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON payments TO pykotaadmin;
+GRANT SELECT, UPDATE ON payments_id_seq TO pykotaadmin;
+GRANT SELECT ON payments TO pykotauser;
