Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 1077)
+++ /pykota/trunk/pykota/tool.py (revision 1079)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.46  2003/07/09 20:17:07  jalet
+# Email field added to PostgreSQL schema
+#
 # Revision 1.45  2003/07/08 19:43:51  jalet
 # Configurable warning messages.
@@ -327,8 +330,8 @@
         server.quit()
         
-    def sendMessageToUser(self, admin, adminmail, username, subject, message) :
+    def sendMessageToUser(self, admin, adminmail, user, subject, message) :
         """Sends an email message to a user."""
         message += _("\n\nPlease contact your system administrator :\n\n\t%s - <%s>\n") % (admin, adminmail)
-        self.sendMessage(adminmail, username, "Subject: %s\n\n%s" % (subject, message))
+        self.sendMessage(adminmail, user.Email or user.Name, "Subject: %s\n\n%s" % (subject, message))
         
     def sendMessageToAdmin(self, adminmail, subject, message) :
@@ -477,5 +480,5 @@
             for user in self.storage.getGroupMembers(group) :
                 if mailto in [ "BOTH", "USER" ] :
-                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name))
+                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name))
         elif action == "WARN" :    
             adminmessage = _("Print Quota soft limit exceeded for group %s on printer %s") % (group.Name, printer.Name)
@@ -489,5 +492,5 @@
             for user in self.storage.getGroupMembers(group) :
                 if mailto in [ "BOTH", "USER" ] :
-                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), message)
+                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message)
         return action        
         
@@ -506,5 +509,5 @@
             self.logger.log_message(adminmessage)
             if mailto in [ "BOTH", "USER" ] :
-                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name))
+                self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name))
             if mailto in [ "BOTH", "ADMIN" ] :
                 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
@@ -517,5 +520,5 @@
                 else :     
                     message = self.config.getSoftWarn(printer.Name)
-                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Low"), message)
+                self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message)
             if mailto in [ "BOTH", "ADMIN" ] :
                 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
Index: /pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/pgstorage.py (revision 1068)
+++ /pykota/trunk/pykota/storages/pgstorage.py (revision 1079)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.7  2003/07/09 20:17:07  jalet
+# Email field added to PostgreSQL schema
+#
 # Revision 1.6  2003/07/07 11:49:24  jalet
 # Lots of small fixes with the help of PyChecker
@@ -283,5 +286,5 @@
         """Returns the list of users who uses a given printer, along with their quotas."""
         usersandquotas = []
-        result = self.doSearch("SELECT users.id as uid,username,balance,lifetimepaid,limitby,userpquota.id,lifepagecounter,pagecounter,softlimit,hardlimit,datelimit FROM users JOIN userpquota ON users.id=userpquota.userid AND printerid=%s ORDER BY username ASC" % self.doQuote(printer.ident))
+        result = self.doSearch("SELECT users.id as uid,username,balance,lifetimepaid,limitby,email,userpquota.id,lifepagecounter,pagecounter,softlimit,hardlimit,datelimit FROM users JOIN userpquota ON users.id=userpquota.userid AND printerid=%s ORDER BY username ASC" % self.doQuote(printer.ident))
         if result :
             for record in result :
@@ -292,5 +295,5 @@
                     user.AccountBalance = record.get("balance")
                     user.LifeTimePaid = record.get("lifetimepaid")
-                    user.Email = record.get("email")    # TODO : Always None here
+                    user.Email = record.get("email") 
                     user.Exists = 1
                     userpquota = StorageUserPQuota(self, user, printer)
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1078)
+++ /pykota/trunk/pykota/version.py (revision 1079)
@@ -21,5 +21,5 @@
 #
 
-__version__ = "1.14alpha2_unofficial"
+__version__ = "1.14alpha3_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/initscripts/postgresql/README.postgresql
===================================================================
--- /pykota/trunk/initscripts/postgresql/README.postgresql (revision 1046)
+++ /pykota/trunk/initscripts/postgresql/README.postgresql (revision 1079)
@@ -56,10 +56,26 @@
   version of PyKota.
   
-* An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 
-  1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 
   
-* If you are already running an old version of PyKota (<1.03) and 
-  want to upgrade to 1.03, YOU HAVE TO RUN the 
-  upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 
-  WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 
-  YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. 
+  * An SQL script to upgrade a pre-1.14 PyKota Storage DataBase to
+    1.14 is included. Launch it this way on the Quota Storage Server :
+    
+        $ psql -U postgres pykota
+        pykota=# \i upgrade-to-1.14.sql
+        pykota=# \q
+        $
+        
+    This script adds an "email" field for each user. This field, if not    
+    NULL, is used as the email address of the user when sending warning
+    messages in case he is over quota.
+    
+What is below is for historical reasons only, real people don't use  
+such old beasts, and YOU SHOULDN'T EITHER !
+
+  * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 
+    1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 
+  
+  * If you are already running an old version of PyKota (<1.03) and 
+    want to upgrade to 1.03, YOU HAVE TO RUN the 
+    upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 
+    WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 
+    YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. 
Index: /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1021)
+++ /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1079)
@@ -20,4 +20,7 @@
 --
 -- $Log$
+-- Revision 1.3  2003/07/09 20:17:07  jalet
+-- Email field added to PostgreSQL schema
+--
 -- Revision 1.2  2003/06/10 16:37:54  jalet
 -- Deletion of the second user which is not needed anymore.
@@ -59,4 +62,5 @@
 CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL,
                    username TEXT UNIQUE NOT NULL,
+                   email TEXT, 
                    balance FLOAT DEFAULT 0.0,
                    lifetimepaid FLOAT DEFAULT 0.0,
Index: /pykota/trunk/initscripts/postgresql/upgrade-to-1.14.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/upgrade-to-1.14.sql (revision 1079)
+++ /pykota/trunk/initscripts/postgresql/upgrade-to-1.14.sql (revision 1079)
@@ -0,0 +1,41 @@
+--
+-- PyKota - Print Quotas for CUPS and LPRng
+--
+-- (c) 2003 Jerome Alet <alet@librelogiciel.com>
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+-- 
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+--
+-- $Id$
+--
+-- $Log$
+-- Revision 1.1  2003/07/09 20:17:07  jalet
+-- Email field added to PostgreSQL schema
+--
+--
+--
+-- This script has to be used if you already
+-- have a pre-1.14 version of PyKota to upgrade
+-- your database schema. 
+--
+-- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA
+--
+                        
+--                         
+-- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK !
+--
+
+--                         
+-- Modify the old database schema
+--
+ALTER TABLE users ADD COLUMN email TEXT;
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1078)
+++ /pykota/trunk/NEWS (revision 1079)
@@ -22,4 +22,9 @@
 PyKota NEWS :
 
+    - 1.14alpha3 :
+    
+        - Email field added to PostgreSQL database. An upgrade script
+          is included in initscripts/postgresql.
+        
     - 1.14alpha2 :
     
