Changeset 1079

Show
Ignore:
Timestamp:
07/09/03 22:17:07 (21 years ago)
Author:
jalet
Message:

Email field added to PostgreSQL schema

Location:
pykota/trunk
Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/initscripts/postgresql/pykota-postgresql.sql

    r1021 r1079  
    2020-- 
    2121-- $Log$ 
     22-- Revision 1.3  2003/07/09 20:17:07  jalet 
     23-- Email field added to PostgreSQL schema 
     24-- 
    2225-- Revision 1.2  2003/06/10 16:37:54  jalet 
    2326-- Deletion of the second user which is not needed anymore. 
     
    5962CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, 
    6063                   username TEXT UNIQUE NOT NULL, 
     64                   email TEXT,  
    6165                   balance FLOAT DEFAULT 0.0, 
    6266                   lifetimepaid FLOAT DEFAULT 0.0, 
  • pykota/trunk/initscripts/postgresql/README.postgresql

    r1046 r1079  
    5656  version of PyKota. 
    5757   
    58 * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to  
    59   1.01 is still included for historical reasons. PLEASE DON'T USE IT !  
    6058   
    61 * If you are already running an old version of PyKota (<1.03) and  
    62   want to upgrade to 1.03, YOU HAVE TO RUN the  
    63   upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT  
    64   WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF  
    65   YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER.  
     59  * An SQL script to upgrade a pre-1.14 PyKota Storage DataBase to 
     60    1.14 is included. Launch it this way on the Quota Storage Server : 
     61     
     62        $ psql -U postgres pykota 
     63        pykota=# \i upgrade-to-1.14.sql 
     64        pykota=# \q 
     65        $ 
     66         
     67    This script adds an "email" field for each user. This field, if not     
     68    NULL, is used as the email address of the user when sending warning 
     69    messages in case he is over quota. 
     70     
     71What is below is for historical reasons only, real people don't use   
     72such old beasts, and YOU SHOULDN'T EITHER ! 
     73 
     74  * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to  
     75    1.01 is still included for historical reasons. PLEASE DON'T USE IT !  
     76   
     77  * If you are already running an old version of PyKota (<1.03) and  
     78    want to upgrade to 1.03, YOU HAVE TO RUN the  
     79    upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT  
     80    WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF  
     81    YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER.  
  • pykota/trunk/NEWS

    r1078 r1079  
    2222PyKota NEWS : 
    2323 
     24    - 1.14alpha3 : 
     25     
     26        - Email field added to PostgreSQL database. An upgrade script 
     27          is included in initscripts/postgresql. 
     28         
    2429    - 1.14alpha2 : 
    2530     
  • pykota/trunk/pykota/storages/pgstorage.py

    r1068 r1079  
    2121# 
    2222# $Log$ 
     23# Revision 1.7  2003/07/09 20:17:07  jalet 
     24# Email field added to PostgreSQL schema 
     25# 
    2326# Revision 1.6  2003/07/07 11:49:24  jalet 
    2427# Lots of small fixes with the help of PyChecker 
     
    283286        """Returns the list of users who uses a given printer, along with their quotas.""" 
    284287        usersandquotas = [] 
    285         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)) 
     288        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)) 
    286289        if result : 
    287290            for record in result : 
     
    292295                    user.AccountBalance = record.get("balance") 
    293296                    user.LifeTimePaid = record.get("lifetimepaid") 
    294                     user.Email = record.get("email")    # TODO : Always None here 
     297                    user.Email = record.get("email")  
    295298                    user.Exists = 1 
    296299                    userpquota = StorageUserPQuota(self, user, printer) 
  • pykota/trunk/pykota/tool.py

    r1077 r1079  
    2121# 
    2222# $Log$ 
     23# Revision 1.46  2003/07/09 20:17:07  jalet 
     24# Email field added to PostgreSQL schema 
     25# 
    2326# Revision 1.45  2003/07/08 19:43:51  jalet 
    2427# Configurable warning messages. 
     
    327330        server.quit() 
    328331         
    329     def sendMessageToUser(self, admin, adminmail, username, subject, message) : 
     332    def sendMessageToUser(self, admin, adminmail, user, subject, message) : 
    330333        """Sends an email message to a user.""" 
    331334        message += _("\n\nPlease contact your system administrator :\n\n\t%s - <%s>\n") % (admin, adminmail) 
    332         self.sendMessage(adminmail, username, "Subject: %s\n\n%s" % (subject, message)) 
     335        self.sendMessage(adminmail, user.Email or user.Name, "Subject: %s\n\n%s" % (subject, message)) 
    333336         
    334337    def sendMessageToAdmin(self, adminmail, subject, message) : 
     
    477480            for user in self.storage.getGroupMembers(group) : 
    478481                if mailto in [ "BOTH", "USER" ] : 
    479                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
     482                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    480483        elif action == "WARN" :     
    481484            adminmessage = _("Print Quota soft limit exceeded for group %s on printer %s") % (group.Name, printer.Name) 
     
    489492            for user in self.storage.getGroupMembers(group) : 
    490493                if mailto in [ "BOTH", "USER" ] : 
    491                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), message) 
     494                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) 
    492495        return action         
    493496         
     
    506509            self.logger.log_message(adminmessage) 
    507510            if mailto in [ "BOTH", "USER" ] : 
    508                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
     511                self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    509512            if mailto in [ "BOTH", "ADMIN" ] : 
    510513                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     
    517520                else :      
    518521                    message = self.config.getSoftWarn(printer.Name) 
    519                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Low"), message) 
     522                self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message) 
    520523            if mailto in [ "BOTH", "ADMIN" ] : 
    521524                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
  • pykota/trunk/pykota/version.py

    r1078 r1079  
    2121# 
    2222 
    23 __version__ = "1.14alpha2_unofficial" 
     23__version__ = "1.14alpha3_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""