Changeset 1077 for pykota/trunk/pykota/tool.py
- Timestamp:
- 07/08/03 21:43:51 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1068 r1077 21 21 # 22 22 # $Log$ 23 # Revision 1.45 2003/07/08 19:43:51 jalet 24 # Configurable warning messages. 25 # Poor man's treshold value added. 26 # 23 27 # Revision 1.44 2003/07/07 11:49:24 jalet 24 28 # Lots of small fixes with the help of PyChecker … … 337 341 printer = grouppquota.Printer 338 342 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 : 341 344 action = "DENY" 345 elif group.AccountBalance <= self.config.getPoorMan() : 346 action = "WARN" 342 347 else : 343 348 action = "ALLOW" … … 402 407 self.logger.log_message(_("Unable to find user %s's account balance, applying default policy (%s) for printer %s") % (user.Name, action, printer.Name)) 403 408 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 : 406 411 action = "DENY" 412 elif val <= self.config.getPoorMan() : 413 action = "WARN" 407 414 else : 408 415 action = "ALLOW" … … 470 477 for user in self.storage.getGroupMembers(group) : 471 478 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)) 473 480 elif action == "WARN" : 474 481 adminmessage = _("Print Quota soft limit exceeded for group %s on printer %s") % (group.Name, printer.Name) … … 476 483 if mailto in [ "BOTH", "ADMIN" ] : 477 484 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) 478 489 for user in self.storage.getGroupMembers(group) : 479 490 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) 481 492 return action 482 493 … … 495 506 self.logger.log_message(adminmessage) 496 507 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)) 498 509 if mailto in [ "BOTH", "ADMIN" ] : 499 510 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) … … 502 513 self.logger.log_message(adminmessage) 503 514 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) 505 520 if mailto in [ "BOTH", "ADMIN" ] : 506 521 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)