Show
Ignore:
Timestamp:
07/08/03 21:43:51 (21 years ago)
Author:
jalet
Message:

Configurable warning messages.
Poor man's treshold value added.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r1068 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.45  2003/07/08 19:43:51  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.44  2003/07/07 11:49:24  jalet 
    2428# Lots of small fixes with the help of PyChecker 
     
    337341        printer = grouppquota.Printer 
    338342        if group.LimitBy and (group.LimitBy.lower() == "balance") :  
    339             # TODO : there's no warning (no account balance soft limit) 
    340             if float(group.AccountBalance) <= 0.0 : 
     343            if group.AccountBalance <= 0.0 : 
    341344                action = "DENY" 
     345            elif group.AccountBalance <= self.config.getPoorMan() :     
     346                action = "WARN" 
    342347            else :     
    343348                action = "ALLOW" 
     
    402407                self.logger.log_message(_("Unable to find user %s's account balance, applying default policy (%s) for printer %s") % (user.Name, action, printer.Name)) 
    403408            else :     
    404                 # TODO : there's no warning (no account balance soft limit) 
    405                 if float(user.AccountBalance or 0.0) <= 0.0 : 
     409                val = float(user.AccountBalance or 0.0) 
     410                if val <= 0.0 : 
    406411                    action = "DENY" 
     412                elif val <= self.config.getPoorMan() :     
     413                    action = "WARN" 
    407414                else :     
    408415                    action = "ALLOW" 
     
    470477            for user in self.storage.getGroupMembers(group) : 
    471478                if mailto in [ "BOTH", "USER" ] : 
    472                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour group Print Quota is exceeded on printer %s.") % printer.Name) 
     479                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    473480        elif action == "WARN" :     
    474481            adminmessage = _("Print Quota soft limit exceeded for group %s on printer %s") % (group.Name, printer.Name) 
     
    476483            if mailto in [ "BOTH", "ADMIN" ] : 
    477484                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     485            if group.LimitBy and (group.LimitBy.lower() == "balance") :  
     486                message = self.config.getPoorWarn() 
     487            else :      
     488                message = self.config.getSoftWarn(printer.Name) 
    478489            for user in self.storage.getGroupMembers(group) : 
    479490                if mailto in [ "BOTH", "USER" ] : 
    480                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour group Print Quota is almost reached on printer %s.") % printer.Name) 
     491                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), message) 
    481492        return action         
    482493         
     
    495506            self.logger.log_message(adminmessage) 
    496507            if mailto in [ "BOTH", "USER" ] : 
    497                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % printer.Name) 
     508                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    498509            if mailto in [ "BOTH", "ADMIN" ] : 
    499510                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     
    502513            self.logger.log_message(adminmessage) 
    503514            if mailto in [ "BOTH", "USER" ] : 
    504                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % printer.Name) 
     515                if user.LimitBy and (user.LimitBy.lower() == "balance") :  
     516                    message = self.config.getPoorWarn() 
     517                else :      
     518                    message = self.config.getSoftWarn(printer.Name) 
     519                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Low"), message) 
    505520            if mailto in [ "BOTH", "ADMIN" ] : 
    506521                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)