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

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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) :