Changeset 1418 for pykota

Show
Ignore:
Timestamp:
03/24/04 16:15:24 (21 years ago)
Author:
jalet
Message:

Began integration of Henrik Janhagen's work on quota-then-balance
and balance-then-quota

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1366 r1418  
    2424# 
    2525# $Log$ 
     26# Revision 1.71  2004/03/24 15:15:24  jalet 
     27# Began integration of Henrik Janhagen's work on quota-then-balance 
     28# and balance-then-quota 
     29# 
    2630# Revision 1.70  2004/02/27 09:23:21  jalet 
    2731# Minor code reorganisation 
     
    320324                       by its account balance or by its page quota. 
    321325                       The default value is 'quota'. Allowed values 
    322                        are 'quota' and 'balance'. 
     326                       are 'quota' 'balance' 'quota-then-balance' and 
     327                       'balance-then-quota'. 
    323328                        
    324329  -b | --balance b     Sets the user's account balance to b.                      
     
    467472        if limitby : 
    468473            limitby = limitby.strip().lower() 
    469         if limitby and (limitby not in ('quota', 'balance')) :     
     474        if limitby and (limitby not in ('quota', 'balance', 'quota-then-balance', 'balance-then-quota')) :     
    470475            raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
    471476             
  • pykota/trunk/pykota/reporter.py

    r1257 r1418  
    2222# 
    2323# $Log$ 
     24# Revision 1.8  2004/03/24 15:15:24  jalet 
     25# Began integration of Henrik Janhagen's work on quota-then-balance 
     26# and balance-then-quota 
     27# 
    2428# Revision 1.7  2004/01/08 14:10:32  jalet 
    2529# Copyright year changed. 
     
    96100        balance = float(entry.AccountBalance or 0.0) 
    97101        lifetimepaid = float(entry.LifeTimePaid or 0.0) 
    98          
     102         
     103        #balance 
    99104        if entry.LimitBy and (entry.LimitBy.lower() == "balance") :     
    100105            if balance <= 0 : 
     
    107112                datelimit = "" 
    108113                reached = "-B" 
     114 
     115        #balance-then-quota 
     116        elif entry.LimitBy and (entry.LimitBy.lower() == "balance-then-quota") : 
     117            if balance <= 0 : 
     118                if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
     119                    datelimit = "DENY" 
     120                elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
     121                    datelimit = "DENY" 
     122                elif quota.DateLimit is not None : 
     123                    now = DateTime.now() 
     124                    datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
     125                    if now >= datelimit : 
     126                        datelimit = "QUOTA_DENY" 
     127                else : 
     128                    datelimit = "" 
     129                reached = ( ((datelimit == "DENY" ) and "+B") or "-Q") 
     130                datelimit = ( ((datelimit == "QUOTA_DENY") and "DENY") or datelimit) 
     131            elif balance <= self.tool.config.getPoorMan() : 
     132                if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
     133                    datelimit = "WARNING" 
     134                elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
     135                    datelimit = "WARNING" 
     136                elif quota.DateLimit is not None : 
     137                    now = DateTime.now() 
     138                    datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
     139                    if now >= datelimit : 
     140                        datelimit = "QUOTA_DENY" 
     141                else : 
     142                    datelimit = "" 
     143                reached = ( ((datelimit == "WARNING" ) and "?B") or "+Q") 
     144                datelimit = ( ((datelimit == "QUOTA_DENY") and "WARNING") or datelimit) 
     145            else : 
     146                datelimit = "" 
     147                reached = "-B" 
     148 
     149        #Quota-then-balance 
     150        elif entry.LimitBy and (entry.LimitBy.lower() == "quota-then-balance") : 
     151            if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : 
     152                datelimit = "DENY" 
     153            elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : 
     154                datelimit = "DENY" 
     155            elif quota.DateLimit is not None : 
     156                now = DateTime.now() 
     157                datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) 
     158                if now >= datelimit : 
     159                    datelimit = "DENY" 
     160            else : 
     161                datelimit = "" 
     162                 
     163            reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" 
     164 
     165            if (datelimit == "DENY") and (reached == "-Q") and (balance > self.tool.config.getPoorMan()) : 
     166                datelimit = "" 
     167                reached = "-B" 
     168            else : 
     169                reached = (((datelimit == "DENY") and (self.tool.config.getPoorMan() < balance ) and "-B") or reached) 
     170                if (datelimit == "DENY") and (self.tool.config.getPoorMan() < balance) : 
     171                    datelimit = "" 
     172                reached = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "?B") or reached) 
     173                datelimit = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "WARNING") or datelimit) 
     174 
     175        #Quota 
    109176        else : 
    110177            if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) :     
  • pykota/trunk/pykota/storage.py

    r1395 r1418  
    2222# 
    2323# $Log$ 
     24# Revision 1.51  2004/03/24 15:15:24  jalet 
     25# Began integration of Henrik Janhagen's work on quota-then-balance 
     26# and balance-then-quota 
     27# 
    2428# Revision 1.50  2004/03/09 08:05:27  jalet 
    2529# Small fix : only keeps existing quota entries when searching parents 
     
    235239        except AttributeError :     
    236240            limitby = "quota" 
    237         if limitby in ["quota", "balance"] : 
     241        if limitby in ["quota", "balance", "quota-then-balance", "balance-then-quota"] : 
    238242            self.parent.writeUserLimitBy(self, limitby) 
    239243            self.LimitBy = limitby