Changeset 2452

Show
Ignore:
Timestamp:
09/17/05 16:29:43 (19 years ago)
Author:
jerome
Message:

Upgraded database schema.
Added -i | --ingroups command line option to repykota.
Added -C | --comment command line option to edpykota.
Added 'noquota', 'noprint', and 'nochange' as switches for edpykota's
-l | --limitby command line option.
Severity : entirely new features, in need of testers :-)

Location:
pykota/trunk
Files:
16 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2449 r2452  
    823823         
    824824        if self.Action != "DENY" : 
     825            if self.User.LimitBy == "noprint" : 
     826                self.printInfo(_("User %s is not allowed to print at this time.") % self.UserName, "warn") 
     827                self.Action = "DENY" 
     828                 
     829        if self.Action != "DENY" : 
    825830            # If printing is still allowed at this time, we 
    826831            # need to extract the billing code information from the database. 
     
    841846            # No need to do this if the job is denied, this way we 
    842847            # save some database queries. 
    843             self.logdebug("Checking user %s print quota entry on printer %s" \ 
     848            if self.User.LimitBy in ('noquota', 'nochange') : 
     849                self.logdebug("User %s is allowed to print with no limit, no need to check quota." % self.UserName) 
     850            else : 
     851                self.logdebug("Checking user %s print quota entry on printer %s" \ 
    844852                                    % (self.UserName, self.PrinterName)) 
    845             self.Action = self.warnUserPQuota(self.UserPQuota) 
     853                self.Action = self.warnUserPQuota(self.UserPQuota) 
    846854             
    847855        # exports some new environment variables 
     
    912920            self.printInfo(_("Job size : %i") % self.JobSize) 
    913921             
    914             # update the quota for the current user on this printer  
    915             self.printInfo(_("Updating user %s's quota on printer %s") % (self.UserName, self.PrinterName)) 
    916             self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize) 
     922            if self.User.LimitBy == "nochange" : 
     923                # no need to update the quota for the current user on this printer 
     924                self.printInfo(_("User %s's quota on printer %s won't be modified") % (self.UserName, self.PrinterName)) 
     925                self.JobPrice = self.UserPQuota.computeJobPrice(self.JobSize) 
     926            else : 
     927                # update the quota for the current user on this printer  
     928                self.printInfo(_("Updating user %s's quota on printer %s") % (self.UserName, self.PrinterName)) 
     929                self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize) 
    917930             
    918931            # adds the current job to history     
  • pykota/trunk/bin/edpykota

    r2344 r2452  
    100100                        
    101101  -n | --noquota       Doesn't set a quota but only does accounting. 
     102                       This is the same as --limitby noquota. 
    102103   
    103104  -r | --reset         Resets the actual page counter for the user 
     
    112113                       by its account balance or by its page quota. 
    113114                       The default value is 'quota'. Allowed values 
    114                        are 'quota' 'balance' 'quota-then-balance' and 
    115                        'balance-then-quota'. 
    116                        WARNING : quota-then-balance and balance-then-quota 
    117                        are not yet implemented. 
     115                       are 'quota' 'balance' 'noquota' 'noprint'  
     116                       and 'nochange' : 
     117                        
     118                         - quota : limit by number of pages per printer. 
     119                         - balance : limit by number of credits in account. 
     120                         - noquota : no limit, accounting still done. 
     121                         - nochange : no limit, accounting not done.  
     122                         - noprint : printing is denied.  
     123                       NB : nochange and noprint are not supported for groups. 
    118124                        
    119125  -b | --balance b     Sets the user's account balance to b.                      
     
    125131                       Groups don't have a real balance, but the 
    126132                       sum of their users' account balance. 
     133                        
     134  -C | --comment txt   Defines some informational text to be associated 
     135                       with a change to an user's account balance. 
     136                       Only meaningful if -b | --balance is also used. 
    127137                        
    128138  -S | --softlimit sl  Sets the quota soft limit to sl pages.                        
     
    237247         
    238248        softlimit = hardlimit = None 
     249         
     250        if options["noquota"] : 
     251            options["limitby"] = "noquota" 
     252             
     253        limitby = options["limitby"] 
     254        if limitby : 
     255            limitby = limitby.strip().lower() 
     256        if limitby : 
     257            if limitby not in ('quota', 'balance', 'noquota', \ 
     258                                        'noprint', 'nochange') : 
     259                raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
     260            if limitby in ('noquota', 'nochange') :     
     261                options["noquota"] = 1 
     262            if (limitby in ('nochange', 'noprint')) and options["groups"] :     
     263                raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
    239264 
    240265        used = options["used"] 
     
    288313                    charges = [charges[0], None] 
    289314                     
    290         limitby = options["limitby"] 
    291         if limitby : 
    292             limitby = limitby.strip().lower() 
    293         if limitby and (limitby not in ('quota', 'balance', 'quota-then-balance', 'balance-then-quota')) :     
    294             raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
    295              
    296315        if options["ingroups"] :     
    297316            groupnames = [gname.strip() for gname in options["ingroups"].split(',')] 
     
    474493                                    newbalance = float(entry.AccountBalance or 0.0) + balancevalue 
    475494                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 
    476                                     entry.setAccountBalance(newbalance, newlifetimepaid) 
     495                                    entry.setAccountBalance(newbalance, newlifetimepaid, options["comment"]) 
    477496                                else : 
    478497                                    diff = balancevalue - float(entry.AccountBalance or 0.0) 
    479498                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 
    480                                     entry.setAccountBalance(balancevalue, newlifetimepaid) 
     499                                    entry.setAccountBalance(balancevalue, newlifetimepaid, options["comment"]) 
    481500                                changed[entry.Name]["balance"] = balance 
    482501                                 
     
    506525        defaults = { \ 
    507526                     "printer" : "*", \ 
     527                     "comment" : "", \ 
    508528                   } 
    509         short_options = "vhdo:c:l:b:i:naugrp:P:S:H:G:RU:" 
    510         long_options = ["help", "version", "overcharge=", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups=", "used="] 
     529        short_options = "vhdo:c:C:l:b:i:naugrp:P:S:H:G:RU:" 
     530        long_options = ["help", "version", "comment=", \ 
     531                        "overcharge=", "charge=", "delete", "limitby=", \ 
     532                        "balance=", "ingroups=", "noquota", "add", "users", \ 
     533                        "groups", "reset", "hardreset", "prototype=", \ 
     534                        "printer=", "softlimit=", "hardlimit=", "pgroups=", \ 
     535                        "used="] 
    511536         
    512537        # Initializes the command line tool 
     
    538563        options["used"] = options["U"] or options["used"] 
    539564        options["overcharge"] = options["o"] or options["overcharge"] 
     565        options["comment"] = options["C"] or options["comment"] or defaults["comment"] 
    540566         
    541567        if options["help"] : 
     
    553579        elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["overcharge"]) : 
    554580            raise PyKotaToolError, _("incompatible options, see help.") 
     581        elif options["comment"] and not options["balance"] :     
     582            raise PyKotaToolError, _("incompatible options, see help.") 
    555583        else : 
    556584            retcode = editor.main(args, options) 
  • pykota/trunk/bin/repykota

    r2344 r2452  
    5555  -g | --groups        Generates a report on group quota instead of users. 
    5656   
     57  -i | --ingroups g1[,g2...]  Only lists users who are members of these 
     58                              groups. Reserved to PyKota Administrators. 
     59   
    5760  -P | --printer p     Report quotas on this printer only. Actually p can 
    5861                       use wildcards characters to select only 
     
    9295                # no username, means all usernames 
    9396                ugnames = [ "*" ] 
     97                 
     98            if options["ingroups"] : 
     99                groupsnames = options["ingroups"].split(",") 
     100                groups = [self.storage.getGroup(gname) for gname in groupsnames] 
     101                members = {} 
     102                for group in groups : 
     103                    if not group.Exists : 
     104                        self.printInfo("Group %s doesn't exist." % group.Name, "warn") 
     105                    else :     
     106                        for user in self.storage.getGroupMembers(group) : 
     107                            members[user.Name] = user 
     108                ugnames = [ m for m in members.keys() if self.matchString(m, ugnames) ] 
    94109        else :         
    95             # not the root user 
    96110            # reports only the current user 
     111            if options["ingroups"] : 
     112                raise PyKotaToolError, _("Option --ingroups is reserved to PyKota Administrators.") 
     113                 
    97114            username = pwd.getpwuid(os.geteuid())[0] 
    98115            if options["groups"] : 
     
    118135                     "printer" : "*", \ 
    119136                   } 
    120         short_options = "vhugP:" 
    121         long_options = ["help", "version", "users", "groups", "printer="] 
     137        short_options = "vhugi:P:" 
     138        long_options = ["help", "version", "users", "groups", "ingroups=", "printer="] 
    122139         
    123140        # Initializes the command line tool 
     
    134151        options["groups"] = options["g"] or options["groups"] 
    135152        options["printer"] = options["P"] or options["printer"] or defaults["printer"] 
     153        options["ingroups"] = options["i"] or options["ingroups"] 
    136154         
    137155        if options["help"] : 
  • pykota/trunk/docs/edpykota.sgml

    r2237 r2452  
    6060   
    6161  <para> 
     62    In addition to <literal>balance</literal> and <literal>quota</literal>, several other values 
     63    are allowed for the <literal>--limitby</literal> command line option : 
     64    <itemizedlist> 
     65      <listitem> 
     66        <para> 
     67          <literal>noquota</literal> : the user or group can print without any limitation, but 
     68          accounting continues to be done. 
     69        </para> 
     70      </listitem>   
     71      <listitem> 
     72        <para> 
     73          <literal>nochange</literal> : the user can print without any limitation, but 
     74          accounting is not done. 
     75          This value is not supported for users groups. 
     76        </para> 
     77      </listitem>   
     78      <listitem> 
     79        <para> 
     80          <literal>noprint</literal> : the user can not print. 
     81          This value is not supported for users groups. 
     82        </para> 
     83      </listitem>   
     84    </itemizedlist>   
     85  </para> 
     86   
     87  <para> 
    6288    Here's an incomplete list of features : 
    6389     
     
    101127      <listitem> 
    102128        <para> 
    103           Choose the way you will limit printing : either by page quota or by account balance value ; 
     129          Choose the way you will limit printing ; 
    104130        </para> 
    105131      </listitem> 
    106132      <listitem> 
    107133        <para> 
    108           Reset page counters. 
     134          Reset page counters ; 
    109135        </para> 
    110136      </listitem> 
  • pykota/trunk/initscripts/ldap/pykota.schema

    r2318 r2452  
    244244        SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) 
    245245 
    246 # pykotaTemporaryDenied 
    247 attributetype ( 1.3.6.1.4.1.16868.1.1.36 NAME 'pykotaTemporaryDenied' 
    248         DESC 'Indicates if the user is temporarily denied to print' 
    249         SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) 
    250  
    251246# pykotaPassThrough 
    252 attributetype ( 1.3.6.1.4.1.16868.1.1.37 NAME 'pykotaPassThrough' 
     247attributetype ( 1.3.6.1.4.1.16868.1.1.36 NAME 'pykotaPassThrough' 
    253248        DESC 'Indicates if the printer is in pass through mode' 
    254249        SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) 
     
    280275        DESC 'PyKota User Quota on a Printer' 
    281276        MUST ( cn $ pykotaUserName $ pykotaPrinterName ) 
    282         MAY  ( pykotaMaxJobSize $ pykotaTemporaryDenied $ pykotaPageCounter $ pykotaLifePageCounter $ pykotaSoftLimit $ pykotaHardLimit $ pykotaDateLimit $ pykotaWarnCount ) ) 
     277        MAY  ( pykotaMaxJobSize $ pykotaPageCounter $ pykotaLifePageCounter $ pykotaSoftLimit $ pykotaHardLimit $ pykotaDateLimit $ pykotaWarnCount ) ) 
    283278         
    284279# pykotaGroupPQuota         
  • pykota/trunk/initscripts/postgresql/pykota-postgresql.sql

    r2342 r2452  
    8787                        datelimit TIMESTAMP, 
    8888                        maxjobsize INT4, 
    89                         temporarydenied BOOLEAN DEFAULT 'f', 
    9089                        warncount INT4 DEFAULT 0);  
    9190CREATE INDEX userpquota_u_id_ix ON userpquota (userid); 
     
    155154                       userid INT4 REFERENCES users(id), 
    156155                       amount FLOAT, 
     156                       description TEXT, 
    157157                       date TIMESTAMP DEFAULT now()); 
    158158CREATE INDEX payments_date_ix ON payments (date); 
  • pykota/trunk/initscripts/postgresql/README.postgresql

    r2303 r2452  
    5757  database schema are included. You may have to run all 
    5858  of them or only some of them, depending on your  
    59   version of PyKota. 
     59  version of PyKota. Usually running them several times, for 
     60  example if you used several different development versions 
     61  of PyKota, won't do any harm. 
    6062   
     63  * An SQL script to upgrade a 1.22 PyKota Storage DataBase to 
     64    1.23 is included. Launch it this way on the Quota Storage Server : 
     65     
     66        $ psql -U postgres pykota 
     67        pykota=# \i upgrade-to-1.23.sql 
     68        pykota=# \q 
     69        $ 
     70         
     71    This script adds many fields to existing tables, and a table to 
     72    manage billing codes. 
     73     
    6174  * An SQL script to upgrade a 1.20 PyKota Storage DataBase to 
    6275    1.21 is included. Launch it this way on the Quota Storage Server : 
  • pykota/trunk/initscripts/postgresql/upgrade-to-1.23.sql

    r2342 r2452  
    2222-- 
    2323-- This script has to be used if you already 
    24 -- have a pre-1.23alpha12 version of PyKota to upgrade 
     24-- have a pre-1.23alpha30 version of PyKota to upgrade 
    2525-- your database schema.  
    2626-- 
     
    3434ALTER TABLE groups ADD COLUMN description TEXT; 
    3535ALTER TABLE userpquota ADD COLUMN maxjobsize INT4; 
    36 ALTER TABLE userpquota ADD COLUMN temporarydenied BOOLEAN; 
    37 ALTER TABLE userpquota ALTER COLUMN temporarydenied SET DEFAULT 'f'; 
    3836ALTER TABLE grouppquota ADD COLUMN maxjobsize INT4; 
    3937ALTER TABLE printers ADD COLUMN maxjobsize INT4; 
     
    4240ALTER TABLE jobhistory ADD COLUMN precomputedjobsize INT4; 
    4341ALTER TABLE jobhistory ADD COLUMN precomputedjobprice FLOAT; 
     42ALTER TABLE payments ADD COLUMN description TEXT; 
     43 
     44ALTER TABLE userpquota DROP COLUMN temporarydenied; 
    4445 
    4546-- 
     
    4748-- 
    4849-- Just to be sure 
    49 UPDATE userpquota SET temporarydenied='f'; 
    5050UPDATE printers SET passthrough='f'; 
    5151 
  • pykota/trunk/NEWS

    r2449 r2452  
    2222PyKota NEWS : 
    2323        
     24    - 1.23alpha30 : 
     25     
     26        - Database changes : you MUST use upgrade-to-1.23.sql again if you 
     27          use PostgreSQL, or copy the new schema and restart your LDAP 
     28          server if you use LDAP. 
     29           
     30        - The -C | --comment command line switch was added to edpykota to   
     31          attach textual information to modifications done to a user's 
     32          account balance. 
     33           
     34        - The -l | --limitby command line switch to edpykota was modified   
     35          to allow 'noquota', 'nochange', and 'noprint'. See the edpykota 
     36          command's help or manual page for details. 
     37           
     38        - The -i | --ingroups command line switch to repykota allows   
     39          PyKota Administrators to only lists members of the specified 
     40          group or groups (separated with commas). 
     41           
    2442    - 1.23alpha29 : 
    2543     
  • pykota/trunk/pykota/reporter.py

    r2302 r2452  
    8585            warncount = int(quota.WarnCount or 0) 
    8686         
    87         #balance 
    88         if entry.LimitBy and (entry.LimitBy.lower() == "balance") :     
    89             if balance == 0.0 : 
    90                 if entry.OverCharge > 0 : 
    91                     datelimit = "DENY" 
    92                     reached = "+B" 
    93                 else :     
    94                     # overcharging by a negative or nul factor means user is always allowed to print 
    95                     # TODO : do something when printer prices are negative as well ! 
    96                     datelimit = "" 
    97                     reached = "-B" 
    98             elif balance < 0 : 
    99                 datelimit = "DENY" 
    100                 reached = "+B" 
    101             elif balance <= self.tool.config.getPoorMan() : 
    102                 datelimit = "WARNING" 
    103                 reached = "?B" 
    104             else :     
    105                 datelimit = "" 
    106                 reached = "-B" 
    107  
    108         #balance-then-quota 
    109         elif entry.LimitBy and (entry.LimitBy.lower() == "balance-then-quota") : 
    110             if balance <= 0 : 
    111                 if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
    112                     datelimit = "DENY" 
    113                 elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
    114                     datelimit = "DENY" 
    115                 elif quota.DateLimit is not None : 
    116                     now = DateTime.now() 
    117                     datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
    118                     if now >= datelimit : 
    119                         datelimit = "QUOTA_DENY" 
    120                 else : 
    121                     datelimit = "" 
    122                 reached = ( ((datelimit == "DENY" ) and "+B") or "-Q") 
    123                 datelimit = ( ((datelimit == "QUOTA_DENY") and "DENY") or datelimit) 
    124             elif balance <= self.tool.config.getPoorMan() : 
    125                 if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
    126                     datelimit = "WARNING" 
    127                 elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
    128                     datelimit = "WARNING" 
    129                 elif quota.DateLimit is not None : 
    130                     now = DateTime.now() 
    131                     datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
    132                     if now >= datelimit : 
    133                         datelimit = "QUOTA_DENY" 
    134                 else : 
    135                     datelimit = "" 
    136                 reached = ( ((datelimit == "WARNING" ) and "?B") or "+Q") 
    137                 datelimit = ( ((datelimit == "QUOTA_DENY") and "WARNING") or datelimit) 
    138             else : 
    139                 datelimit = "" 
    140                 reached = "-B" 
    141  
    142         #Quota-then-balance 
    143         elif entry.LimitBy and (entry.LimitBy.lower() == "quota-then-balance") : 
    144             if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
    145                 datelimit = "DENY" 
    146             elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
    147                 datelimit = "DENY" 
    148             elif quota.DateLimit is not None : 
    149                 now = DateTime.now() 
    150                 datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
    151                 if now >= datelimit : 
    152                     datelimit = "DENY" 
    153             else : 
    154                 datelimit = "" 
    155                  
    156             reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" 
    157  
    158             if (datelimit == "DENY") and (reached == "-Q") and (balance > self.tool.config.getPoorMan()) : 
    159                 datelimit = "" 
    160                 reached = "-B" 
    161             else : 
    162                 reached = (((datelimit == "DENY") and (self.tool.config.getPoorMan() < balance ) and "-B") or reached) 
    163                 if (datelimit == "DENY") and (self.tool.config.getPoorMan() < balance) : 
    164                     datelimit = "" 
    165                 reached = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "?B") or reached) 
    166                 datelimit = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "WARNING") or datelimit) 
    167  
    168         #Quota 
    169         else : 
     87        if (not entry.LimitBy) or (entry.LimitBy.lower() == "quota") : 
    17088            if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) :     
    17189                datelimit = "DENY" 
     
    18098                datelimit = "" 
    18199            reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" 
     100        else : 
     101            if entry.LimitBy.lower() == "balance" : 
     102                if balance == 0.0 : 
     103                    if entry.OverCharge > 0 : 
     104                        datelimit = "DENY" 
     105                        reached = "+B" 
     106                    else :     
     107                        # overcharging by a negative or nul factor means user is always allowed to print 
     108                        # TODO : do something when printer prices are negative as well ! 
     109                        datelimit = "" 
     110                        reached = "-B" 
     111                elif balance < 0 : 
     112                    datelimit = "DENY" 
     113                    reached = "+B" 
     114                elif balance <= self.tool.config.getPoorMan() : 
     115                    datelimit = "WARNING" 
     116                    reached = "?B" 
     117                else :     
     118                    datelimit = "" 
     119                    reached = "-B" 
     120            elif entry.LimitBy.lower() == "noquota" : 
     121                reached = "NQ" 
     122                datelimit = "" 
     123            elif entry.LimitBy.lower() == "nochange" : 
     124                reached = "NC" 
     125                datelimit = "" 
     126            else : 
     127                # noprint 
     128                reached = "NP" 
     129                datelimit = "DENY" 
    182130             
    183131        strbalance = ("%5.2f" % balance)[:10] 
  • pykota/trunk/pykota/storage.py

    r2451 r2452  
    5959        self.AccountBalance = float(self.AccountBalance or 0.0) - amount 
    6060         
    61     def setAccountBalance(self, balance, lifetimepaid) :     
     61    def setAccountBalance(self, balance, lifetimepaid, comment="") : 
    6262        """Sets the user's account balance in case he pays more money.""" 
    6363        diff = float(lifetimepaid or 0.0) - float(self.LifeTimePaid or 0.0) 
     
    6565        try : 
    6666            self.parent.writeUserAccountBalance(self, balance, lifetimepaid) 
    67             self.parent.writeNewPayment(self, diff) 
     67            self.parent.writeNewPayment(self, diff, comment) 
    6868        except PyKotaStorageError, msg :     
    6969            self.parent.rollbackTransaction() 
     
    8080        except AttributeError :     
    8181            limitby = "quota" 
    82         if limitby in ["quota", "balance", "quota-then-balance", "balance-then-quota"] : 
     82        if limitby in ["quota", "balance", \ 
     83                       "noquota", "noprint", "nochange"] : 
    8384            self.parent.writeUserLimitBy(self, limitby) 
    8485            self.LimitBy = limitby 
     
    120121        except AttributeError :     
    121122            limitby = "quota" 
    122         if limitby in ["quota", "balance"] : 
     123        if limitby in ["quota", "balance", "noquota"] : 
    123124            self.parent.writeGroupLimitBy(self, limitby) 
    124125            self.LimitBy = limitby 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2418 r2452  
    382382                user.Payments = [] 
    383383                for payment in fields.get("pykotaPayments", []) : 
    384                     (date, amount) = payment.split(" # ") 
    385                     user.Payments.append((date, float(amount))) 
     384                    try : 
     385                        (date, amount, description) = payment.split(" # ") 
     386                    except ValueError : 
     387                        # Payment with no description (old Payment) 
     388                        (date, amount) = payment.split(" # ") 
     389                        description = "" 
     390                    else :     
     391                        description = self.databaseToUserCharset(description) 
     392                    user.Payments.append((date, float(amount), description)) 
    386393            user.Exists = 1 
    387394        return user 
     
    935942        return self.doModify(user.idbalance, fields)          
    936943             
    937     def writeNewPayment(self, user, amount) :         
     944    def writeNewPayment(self, user, amount, comment="") : 
    938945        """Adds a new payment to the payments history.""" 
    939946        payments = [] 
    940947        for payment in user.Payments : 
    941             payments.append("%s # %s" % (payment[0], str(payment[1]))) 
    942         payments.append("%s # %s" % (str(DateTime.now()), str(amount))) 
     948            payments.append("%s # %s # %s" % (payment[0], str(payment[1]), payment[2])) 
     949        payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), self.userCharsetToDatabase(comment))) 
    943950        fields = { 
    944951                   "pykotaPayments" : payments, 
     
    13041311        entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 
    13051312        if entries : 
    1306             result = [ ("username", "amount", "date") ] 
     1313            result = [ ("username", "amount", "date", "description") ] 
    13071314            for entry in entries : 
    1308                 for (date, amount) in entry.Payments : 
    1309                     result.append((entry.Name, amount, date)) 
     1315                for (date, amount, description) in entry.Payments : 
     1316                    result.append((entry.Name, amount, date, description)) 
    13101317            return result         
    13111318         
  • pykota/trunk/pykota/storages/sql.py

    r2388 r2452  
    514514            self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident))) 
    515515             
    516     def writeNewPayment(self, user, amount) :         
     516    def writeNewPayment(self, user, amount, comment="") : 
    517517        """Adds a new payment to the payments history.""" 
    518         self.doModify("INSERT INTO payments (userid, amount) VALUES (%s, %s)" % (self.doQuote(user.ident), self.doQuote(amount))) 
     518        self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(comment))) 
    519519         
    520520    def writeLastJobSize(self, lastjob, jobsize, jobprice) :         
  • pykota/trunk/pykota/tool.py

    r2409 r2452  
    485485        # first we check any group the user is a member of 
    486486        for group in self.storage.getUserGroups(user) : 
    487             grouppquota = self.storage.getGroupPQuota(group, printer) 
    488             # for the printer and all its parents 
    489             for gpquota in [ grouppquota ] + grouppquota.ParentPrintersGroupPQuota : 
    490                 if gpquota.Exists : 
    491                     action = self.checkGroupPQuota(gpquota) 
    492                     if action == "DENY" : 
    493                         return action 
    494                     elif action == "WARN" :     
    495                         warned = 1 
     487            # No need to check anything if the group is in noquota mode 
     488            if group.LimitBy != "noquota" : 
     489                grouppquota = self.storage.getGroupPQuota(group, printer) 
     490                # for the printer and all its parents 
     491                for gpquota in [ grouppquota ] + grouppquota.ParentPrintersGroupPQuota : 
     492                    if gpquota.Exists : 
     493                        action = self.checkGroupPQuota(gpquota) 
     494                        if action == "DENY" : 
     495                            return action 
     496                        elif action == "WARN" :     
     497                            warned = 1 
    496498                         
    497499        # Then we check the user's account balance 
  • pykota/trunk/pykota/version.py

    r2447 r2452  
    2222# 
    2323 
    24 __version__ = "1.23alpha29_unofficial" 
     24__version__ = "1.23alpha30_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng." 
  • pykota/trunk/TODO

    r2450 r2452  
    2828          a freemoney/freepages attribute which will be decremented/incremented 
    2929          **before** the real one. 
    30            
    31         - Very good idea from Martin Oesterund : comment field for 
    32           payments !!! 
    33            
    34         - Another one : add a third value like 'nocheck' or something 
    35           like that to allow an user to print with no limitation while 
    36           still updating the balance and number of pages printed. 
    3730           
    3831        - Make the SNMP and PJL delay and number of loops a new configuration 
     
    8275          PyKota for example, or something like that. 
    8376         
    84         - Finish implementation of quota-then-balance and  
    85           balance-then-quota. 
    86            
    8777        - Introduce the pkusers command. 
    8878          pkusers --nogroup 
    8979          pkusers --ingroups gr1,gr2,... --outgroups gr3,gr4,... 
    90            
    91         - Allow the --ingroups command line option to repykota, to 
    92           report only users members of the specified groups. 
    9380           
    9481        - Documentation...