Show
Ignore:
Timestamp:
06/06/04 00:03:50 (20 years ago)
Author:
jalet
Message:

Payments history is now stored in database

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1520 r1522  
    2222# 
    2323# $Log$ 
     24# Revision 1.68  2004/06/05 22:03:50  jalet 
     25# Payments history is now stored in database 
     26# 
    2427# Revision 1.67  2004/06/03 23:14:10  jalet 
    2528# Now stores the job's size in bytes in the database. 
     
    257260import time 
    258261import md5 
     262from mx import DateTime 
    259263 
    260264from pykota.storage import PyKotaStorageError,BaseStorage,StorageObject,StorageUser,StorageGroup,StoragePrinter,StorageJob,StorageLastJob,StorageUserPQuota,StorageGroupPQuota 
     
    477481            if user.LimitBy is not None : 
    478482                user.LimitBy = user.LimitBy[0] 
    479             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid"], base=self.info["balancebase"]) 
     483            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], base=self.info["balancebase"]) 
    480484            if result : 
    481485                fields = result[0][1] 
     
    495499                        user.LifeTimePaid = float(user.LifeTimePaid[0]) 
    496500                user.LifeTimePaid = user.LifeTimePaid or 0.0         
     501                user.Payments = [] 
     502                for payment in fields.get("pykotaPayments", []) : 
     503                    (date, amount) = payment.split(" # ") 
     504                    user.Payments.append((date, amount)) 
    497505            user.Exists = 1 
    498506        return user 
     
    944952        return self.doModify(user.idbalance, fields)          
    945953             
     954    def writeNewPayment(self, user, amount) :         
     955        """Adds a new payment to the payments history.""" 
     956        payments = [] 
     957        for payment in user.Payments : 
     958            payments.append("%s # %s" % (payment[0], str(payment[1]))) 
     959        payments.append("%s # %s" % (str(DateTime.now()), str(amount))) 
     960        fields = { 
     961                   "pykotaPayments" : payments, 
     962                 } 
     963        return self.doModify(user.idbalance, fields)          
     964         
    946965    def writeLastJobSize(self, lastjob, jobsize, jobprice) :         
    947966        """Sets the last job's size permanently."""