Changeset 2030

Show
Ignore:
Timestamp:
01/18/05 20:47:50 (19 years ago)
Author:
jalet
Message:

Big bug fix wrt the datelimit attribute

Location:
pykota/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r2028 r2030  
    2424# 
    2525# $Log$ 
     26# Revision 1.85  2005/01/18 19:47:49  jalet 
     27# Big bug fix wrt the datelimit attribute 
     28# 
    2629# Revision 1.84  2005/01/17 08:44:23  jalet 
    2730# Modified copyright years 
     
    691694                            changed[entry.Name]["limitby"] = limitby 
    692695                     
     696                    if options["reset"] : 
     697                        entrypquota.reset() 
     698                         
     699                    if options["hardreset"] :     
     700                        entrypquota.hardreset() 
     701                         
    693702                    if not options["groups"] : 
    694                         if options["reset"] : 
    695                             entrypquota.reset() 
    696                         if options["hardreset"] :     
    697                             entrypquota.hardreset() 
    698703                        if options["used"] : 
    699704                            entrypquota.setUsage(used) 
     
    773778        elif options["noquota"] and (options["prototype"] or options["hardlimit"] or options["softlimit"]) : 
    774779            raise PyKotaToolError, _("incompatible options, see help.") 
    775         elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["reset"] or options["hardreset"]) : 
     780        elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"]) : 
    776781            raise PyKotaToolError, _("incompatible options, see help.") 
    777782        else : 
  • pykota/trunk/NEWS

    r2028 r2030  
    2222PyKota NEWS : 
    2323 
     24    - 1.21alpha20 : 
     25     
     26        - Big bug fix wrt the datelimit field which was never 
     27          reset. 
     28           
    2429    - 1.21alpha19 : 
    2530     
  • pykota/trunk/pykota/storage.py

    r1967 r2030  
    2222# 
    2323# $Log$ 
     24# Revision 1.67  2005/01/18 19:47:50  jalet 
     25# Big bug fix wrt the datelimit attribute 
     26# 
    2427# Revision 1.66  2004/12/02 21:24:50  jalet 
    2528# Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow 
     
    447450        vused = int(used) 
    448451        if used.startswith("+") or used.startswith("-") : 
    449            self.parent.increaseUserPQuotaPagesCounters(self, vused) 
    450            self.PageCounter += vused 
    451            self.LifePageCounter += vused 
     452            self.parent.beginTransaction() 
     453            try : 
     454                self.parent.increaseUserPQuotaPagesCounters(self, vused) 
     455                self.parent.writeUserPQuotaDateLimit(self, None) 
     456            except PyKotaStorageError, msg :     
     457                self.parent.rollbackTransaction() 
     458                raise PyKotaStorageError, msg 
     459            else : 
     460                self.parent.commitTransaction() 
     461            self.PageCounter += vused 
     462            self.LifePageCounter += vused 
    452463        else : 
    453            self.parent.writeUserPQuotaPagesCounters(self, vused, vused) 
    454            self.PageCounter = self.LifePageCounter = vused 
     464            self.parent.writeUserPQuotaPagesCounters(self, vused, vused) 
     465            self.PageCounter = self.LifePageCounter = vused 
     466        self.DateLimit = None 
    455467 
    456468    def reset(self) :     
     
    458470        self.parent.writeUserPQuotaPagesCounters(self, 0, int(self.LifePageCounter or 0)) 
    459471        self.PageCounter = 0 
     472        self.DateLimit = None 
    460473         
    461474    def hardreset(self) :     
     
    463476        self.parent.writeUserPQuotaPagesCounters(self, 0, 0) 
    464477        self.PageCounter = self.LifePageCounter = 0 
     478        self.DateLimit = None 
    465479         
    466480    def computeJobPrice(self, jobsize) :     
     
    512526            raise AttributeError, name 
    513527         
     528    def reset(self) :     
     529        """Resets page counter to 0.""" 
     530        self.parent.beginTransaction() 
     531        try : 
     532            for user in self.parent.getGroupMembers(self.Group) : 
     533                uq = self.parent.getUserPQuota(user, self.Printer) 
     534                uq.reset() 
     535            self.parent.writeGroupPQuotaDateLimit(self, None) 
     536        except PyKotaStorageError, msg :     
     537            self.parent.rollbackTransaction() 
     538            raise PyKotaStorageError, msg 
     539        else :     
     540            self.parent.commitTransaction() 
     541        self.PageCounter = 0 
     542        self.DateLimit = None 
     543         
     544    def hardreset(self) :     
     545        """Resets actual and life time page counters to 0.""" 
     546        self.parent.beginTransaction() 
     547        try : 
     548            for user in self.parent.getGroupMembers(self.Group) : 
     549                uq = self.parent.getUserPQuota(user, self.Printer) 
     550                uq.hardreset() 
     551            self.parent.writeGroupPQuotaDateLimit(self, None) 
     552        except PyKotaStorageError, msg :     
     553            self.parent.rollbackTransaction() 
     554            raise PyKotaStorageError, msg 
     555        else :     
     556            self.parent.commitTransaction() 
     557        self.PageCounter = self.LifePageCounter = 0 
     558        self.DateLimit = None 
     559         
    514560    def setDateLimit(self, datelimit) :     
    515561        """Sets the date limit for this quota.""" 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2000 r2030  
    2222# 
    2323# $Log$ 
     24# Revision 1.95  2005/01/18 19:47:50  jalet 
     25# Big bug fix wrt the datelimit attribute 
     26# 
    2427# Revision 1.94  2005/01/01 18:53:27  jalet 
    2528# Implemented in the LDAP backend code the same fix than in PostgreSQL backend 
     
    11671170                   "pykotaPageCounter" : str(newpagecounter), 
    11681171                   "pykotaLifePageCounter" : str(newlifepagecounter), 
     1172                   "pykotaDateLimit" : None, 
    11691173                 }   
    11701174        return self.doModify(userpquota.ident, fields)          
  • pykota/trunk/pykota/storages/sql.py

    r1999 r2030  
    2222# 
    2323# $Log$ 
     24# Revision 1.64  2005/01/18 19:47:50  jalet 
     25# Big bug fix wrt the datelimit attribute 
     26# 
    2427# Revision 1.63  2005/01/01 08:16:17  jalet 
    2528# Fixed a problem which occured when 'limitby' was unset in the PostgreSQL 
     
    522525    def writeUserPQuotaPagesCounters(self, userpquota, newpagecounter, newlifepagecounter) :     
    523526        """Sets the new page counters permanently for a user print quota.""" 
    524         self.doModify("UPDATE userpquota SET pagecounter=%s,lifepagecounter=%s WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident))) 
     527        self.doModify("UPDATE userpquota SET pagecounter=%s, lifepagecounter=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident))) 
    525528        
    526529    def decreaseUserAccountBalance(self, user, amount) :     
  • pykota/trunk/pykota/version.py

    r2020 r2030  
    2222# 
    2323 
    24 __version__ = "1.21alpha19_unofficial" 
     24__version__ = "1.21alpha20_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""