Changeset 3086

Show
Ignore:
Timestamp:
11/30/06 18:13:31 (17 years ago)
Author:
jerome
Message:

Fixed a big problem with the user's overcharging factor in the LDAP backend.

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r3084 r3086  
    2222PyKota NEWS : 
    2323        
     24    - 1.25alpha18 (2006-11-30) : 
     25     
     26        - Fixed a severe bug in the LDAP backend wrt the overcharging factor. 
     27         
    2428    - 1.25alpha17 (2006-11-27) : 
    2529     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r3056 r3086  
    358358        user = StorageUser(self, username) 
    359359        username = self.userCharsetToDatabase(username) 
    360         result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], base=self.info["userbase"]) 
     360        result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "description"], base=self.info["userbase"]) 
    361361        if result : 
    362362            fields = result[0][1] 
     
    365365            user.Email = fields.get(self.info["usermail"], [None])[0] 
    366366            user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    367             user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 
    368             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], base=self.info["balancebase"]) 
     367            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments", "pykotaOverCharge"], base=self.info["balancebase"]) 
    369368            if not result : 
    370369                raise PyKotaStorageError, _("No pykotaAccountBalance object found for user %s. Did you create LDAP entries manually ?") % username 
     
    380379                user.AccountBalance = user.AccountBalance or 0.0         
    381380                user.LifeTimePaid = fields.get("pykotaLifeTimePaid") 
     381                user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 
    382382                if user.LifeTimePaid is not None : 
    383383                    if user.LifeTimePaid[0].upper() == "NONE" : 
     
    725725        # see comment at the same place in pgstorage.py 
    726726        result = self.doSearch("objectClass=pykotaAccount", \ 
    727                                   ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], \ 
     727                                  ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "description"], \ 
    728728                                  base=self.info["userbase"]) 
    729729        if result : 
     
    743743                    user.Email = fields.get(self.info["usermail"], [None])[0] 
    744744                    user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    745                     user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 
    746745                    user.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    747746                    uname = self.userCharsetToDatabase(username) 
    748747                    result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \ 
    749748                                              (uname, self.info["balancerdn"], uname), \ 
    750                                               ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], \ 
     749                                              ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments", "pykotaOverCharge"], \ 
    751750                                              base=self.info["balancebase"]) 
    752751                    if not result : 
     
    755754                        fields = result[0][1] 
    756755                        user.idbalance = result[0][0] 
     756                        user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 
    757757                        user.AccountBalance = fields.get("pykotaBalance") 
    758758                        if user.AccountBalance is not None : 
     
    916916                       "pykotaUserName" : uname, 
    917917                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    918                        "pykotaOverCharge" : str(user.OverCharge), 
    919918                       "description" : self.userCharsetToDatabase(user.Description or ""), 
    920919                       self.info["usermail"] : user.Email or "", 
     
    937936                fields.update(newfields) 
    938937                fields.update({ "pykotaBalance" : str(user.AccountBalance or 0.0), 
     938                                "pykotaOverCharge" : str(user.OverCharge), 
    939939                                "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), })    
    940940                self.doModify(dn, fields) 
     
    953953                           "cn" : uname, 
    954954                           "pykotaBalance" : str(user.AccountBalance or 0.0), 
     955                           "pykotaOverCharge" : str(user.OverCharge), 
    955956                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),  
    956957                         }  
     
    968969                           "cn" : uname, 
    969970                           "pykotaBalance" : str(user.AccountBalance or 0.0), 
     971                           "pykotaOverCharge" : str(user.OverCharge), 
    970972                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),   
    971973                         }  
     
    11201122        newfields = { 
    11211123                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    1122                        "pykotaOverCharge" : str(user.OverCharge), 
    11231124                       "description" : self.userCharsetToDatabase(user.Description or ""),  
    11241125                       self.info["usermail"] : user.Email or "", 
     
    11281129        newfields = { "pykotaBalance" : str(user.AccountBalance or 0.0), 
    11291130                      "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),  
     1131                      "pykotaOverCharge" : str(user.OverCharge), 
    11301132                    } 
    11311133        self.doModify(user.idbalance, newfields) 
     
    15911593        entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 
    15921594        if entries : 
    1593             result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email", "description") ] 
     1595            result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email", "description", "overcharge") ] 
    15941596            for entry in entries : 
    1595                 result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email, entry.Description)) 
     1597                result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email, entry.Description, entry.OverCharge)) 
    15961598            return result  
    15971599         
  • pykota/trunk/pykota/version.py

    r3073 r3086  
    2222# 
    2323 
    24 __version__ = "1.25alpha17_unofficial" 
     24__version__ = "1.25alpha18_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS."