Changeset 852 for pykota/trunk/pykota

Show
Ignore:
Timestamp:
03/16/03 00:01:28 (21 years ago)
Author:
jalet
Message:

New mailto option in configuration file added.
No time to test this tonight (although it should work).

Location:
pykota/trunk/pykota
Files:
2 modified

Legend:

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

    r804 r852  
    1515# 
    1616# $Log$ 
     17# Revision 1.17  2003/03/15 23:01:28  jalet 
     18# New mailto option in configuration file added. 
     19# No time to test this tonight (although it should work). 
     20# 
    1721# Revision 1.16  2003/02/17 23:01:56  jalet 
    1822# Typos 
     
    189193        return self.getPrinterOption(printer, "admin") 
    190194         
     195    def getMailTo(self, printer) :     
     196        """Returns the recipient of email messages.""" 
     197        validmailtos = [ "DEVNULL", "BOTH", "USER", "ADMIN" ] 
     198        mailto = self.getPrinterOption(printer, "mailto").upper() 
     199        if mailto not in validmailtos : 
     200            raise PyKotaConfigError, _("Option mailto in section %s only supports values in %s") % (printer, str(validmailtos)) 
     201        return mailto     
     202         
    191203    def getGraceDelay(self, printer) :     
    192204        """Returns the grace delay in days.""" 
  • pykota/trunk/pykota/tool.py

    r844 r852  
    1515# 
    1616# $Log$ 
     17# Revision 1.27  2003/03/15 23:01:28  jalet 
     18# New mailto option in configuration file added. 
     19# No time to test this tonight (although it should work). 
     20# 
    1721# Revision 1.26  2003/03/09 23:58:16  jalet 
    1822# Comment 
     
    312316        admin = self.config.getAdmin(pname) 
    313317        adminmail = self.config.getAdminMail(pname) 
     318        mailto = self.config.getMailTo(pname) 
    314319        action = self.checkUserPQuota(username, pname) 
    315320        if action.startswith("POLICY_") : 
     
    318323            adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname) 
    319324            self.logger.log_message(adminmessage) 
    320             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) 
    321             self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     325            if mailto in [ "BOTH", "USER" ] : 
     326                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) 
     327            if mailto in [ "BOTH", "ADMIN" ] : 
     328                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    322329        elif action == "WARN" :     
    323330            adminmessage = _("Print Quota soft limit exceeded for user %s on printer %s") % (username, pname) 
    324331            self.logger.log_message(adminmessage) 
    325             self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % pname) 
    326             self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     332            if mailto in [ "BOTH", "USER" ] : 
     333                self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % pname) 
     334            if mailto in [ "BOTH", "ADMIN" ] : 
     335                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    327336        return action         
    328337