608 | | actions = [] |
609 | | for upq in [userpquota] + userpquota.ParentPrintersUserPQuota : |
610 | | printer = upq.Printer |
611 | | admin = self.config.getAdmin(printer.Name) |
612 | | adminmail = self.config.getAdminMail(printer.Name) |
613 | | (mailto, arguments) = self.config.getMailTo(printer.Name) |
614 | | self.logdebug("Checking quota for user %s on printer %s" % (upq.User.Name, printer.Name)) |
615 | | action = self.checkUserPQuota(upq) |
616 | | self.logdebug("Result is %s" % action) |
617 | | if action.startswith("POLICY_") : |
618 | | action = action[7:] |
619 | | if action == "DENY" : |
620 | | adminmessage = _("Print Quota exceeded for user %s on printer %s") % (user.Name, printer.Name) |
621 | | self.logger.log_message(adminmessage) |
622 | | if mailto in [ "BOTH", "USER", "EXTERNAL" ] : |
623 | | message = self.config.getHardWarn(printer.Name) |
624 | | if mailto != "EXTERNAL" : |
625 | | self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) |
626 | | else : |
627 | | self.externalMailTo(arguments, action, user, printer, message) |
628 | | if mailto in [ "BOTH", "ADMIN" ] : |
629 | | self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) |
630 | | elif action == "WARN" : |
631 | | adminmessage = _("Print Quota low for user %s on printer %s") % (user.Name, printer.Name) |
632 | | self.logger.log_message(adminmessage) |
633 | | if mailto in [ "BOTH", "USER", "EXTERNAL" ] : |
634 | | if user.LimitBy and (user.LimitBy.lower() == "balance") : |
635 | | message = self.config.getPoorWarn() |
636 | | else : |
637 | | message = self.config.getSoftWarn(printer.Name) |
638 | | if mailto != "EXTERNAL" : |
639 | | self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message) |
640 | | else : |
641 | | self.externalMailTo(arguments, action, user, printer, message) |
642 | | if mailto in [ "BOTH", "ADMIN" ] : |
643 | | self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) |
644 | | actions.append(action) |
645 | | if "DENY" in actions : |
646 | | self.logdebug("Final result is %s" % action) |
647 | | return "DENY" |
648 | | elif "WARN" in actions : |
649 | | self.logdebug("Final result is %s" % action) |
650 | | return "WARN" |
651 | | else : |
652 | | self.logdebug("Final result is %s" % action) |
653 | | return "ALLOW" |
| 607 | printer = userpquota.Printer |
| 608 | admin = self.config.getAdmin(printer.Name) |
| 609 | adminmail = self.config.getAdminMail(printer.Name) |
| 610 | (mailto, arguments) = self.config.getMailTo(printer.Name) |
| 611 | action = self.checkUserPQuota(userpquota) |
| 612 | if action.startswith("POLICY_") : |
| 613 | action = action[7:] |
| 614 | if action == "DENY" : |
| 615 | adminmessage = _("Print Quota exceeded for user %s on printer %s") % (user.Name, printer.Name) |
| 616 | self.logger.log_message(adminmessage) |
| 617 | if mailto in [ "BOTH", "USER", "EXTERNAL" ] : |
| 618 | message = self.config.getHardWarn(printer.Name) |
| 619 | if mailto != "EXTERNAL" : |
| 620 | self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) |
| 621 | else : |
| 622 | self.externalMailTo(arguments, action, user, printer, message) |
| 623 | if mailto in [ "BOTH", "ADMIN" ] : |
| 624 | self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) |
| 625 | elif action == "WARN" : |
| 626 | adminmessage = _("Print Quota low for user %s on printer %s") % (user.Name, printer.Name) |
| 627 | self.logger.log_message(adminmessage) |
| 628 | if mailto in [ "BOTH", "USER", "EXTERNAL" ] : |
| 629 | if user.LimitBy and (user.LimitBy.lower() == "balance") : |
| 630 | message = self.config.getPoorWarn() |
| 631 | else : |
| 632 | message = self.config.getSoftWarn(printer.Name) |
| 633 | if mailto != "EXTERNAL" : |
| 634 | self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message) |
| 635 | else : |
| 636 | self.externalMailTo(arguments, action, user, printer, message) |
| 637 | if mailto in [ "BOTH", "ADMIN" ] : |
| 638 | self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) |
| 639 | return action |