Index: pykota/trunk/pykota/tool.py
===================================================================
--- pykota/trunk/pykota/tool.py (revision 825)
+++ pykota/trunk/pykota/tool.py (revision 834)
@@ -15,4 +15,7 @@
 #
 # $Log$
+# Revision 1.25  2003/03/07 22:56:14  jalet
+# 0.99 is out with some bug fixes.
+#
 # Revision 1.24  2003/02/27 23:48:41  jalet
 # Correctly maps PyKota's log levels to syslog log levels
@@ -254,9 +257,8 @@
             policy = self.config.getPrinterPolicy(printername)
             if policy in [None, "ALLOW"] :
-                action = "ALLOW"
+                action = "POLICY_ALLOW"
             else :    
-                action = "DENY"
+                action = "POLICY_DENY"
             self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action))
-            return (action, None, None)
         else :    
             pagecounter = quota["pagecounter"]
@@ -264,26 +266,36 @@
             hardlimit = quota["hardlimit"]
             datelimit = quota["datelimit"]
-            if datelimit is not None :
-                datelimit = DateTime.ISO.ParseDateTime(datelimit)
             if softlimit is not None :
                 if pagecounter < softlimit :
                     action = "ALLOW"
-                elif hardlimit is not None :
-                    if softlimit <= pagecounter < hardlimit :    
-                        now = DateTime.now()
-                        if datelimit is None :
-                            datelimit = now + self.config.getGraceDelay(printername)
-                            self.storage.setDateLimit(username, printername, datelimit)
-                        if now < datelimit :
-                            action = "WARN"
-                        else :    
+                else :    
+                    if hardlimit is None :
+                        # only a soft limit, this is equivalent to having only a hard limit
+                        action = "DENY"
+                    else :    
+                        if softlimit <= pagecounter < hardlimit :    
+                            now = DateTime.now()
+                            if datelimit is not None :
+                                datelimit = DateTime.ISO.ParseDateTime(datelimit)
+                            else :
+                                datelimit = now + self.config.getGraceDelay(printername)
+                                self.storage.setDateLimit(username, printername, datelimit)
+                            if now < datelimit :
+                                action = "WARN"
+                            else :    
+                                action = "DENY"
+                        else :         
                             action = "DENY"
-                    else :         
+            else :        
+                if hardlimit is not None :
+                    # no soft limit, only a hard one.
+                    if pagecounter < hardlimit :
+                        action = "ALLOW"
+                    else :      
                         action = "DENY"
-                else :        
-                    action = "DENY"
-            else :        
-                action = "ALLOW"
-            return (action, (hardlimit - pagecounter), datelimit)
+                else :
+                    # Both are unset, no quota
+                    action = "ALLOW"
+        return action
     
     def warnGroupPQuota(self, username, printername=None) :
@@ -297,12 +309,12 @@
         admin = self.config.getAdmin(pname)
         adminmail = self.config.getAdminMail(pname)
-        (action, grace, gracedate) = self.checkUserPQuota(username, pname)
+        action = self.checkUserPQuota(username, pname)
+        if action.startswith("POLICY_") :
+            action = action[7:]
         if action == "DENY" :
-            if (grace is not None) and (gracedate is not None) :
-                # only when both user and printer are known
-                adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname)
-                self.logger.log_message(adminmessage)
-                self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % pname)
-                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
+            adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname)
+            self.logger.log_message(adminmessage)
+            self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % pname)
+            self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
         elif action == "WARN" :    
             adminmessage = _("Print Quota soft limit exceeded for user %s on printer %s") % (username, pname)
Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 827)
+++ pykota/trunk/pykota/version.py (revision 834)
@@ -15,5 +15,5 @@
 #
 
-__version__ = "0.98-unofficial"
+__version__ = "0.99-unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS."""
