Changeset 2631

Show
Ignore:
Timestamp:
01/26/06 16:25:44 (19 years ago)
Author:
jerome
Message:

Added support for the CANCEL command in subprocesses launched from the
overwrite_jobticket directive : this will allow end users to be asked
if they really want to proceed to printing once the new version
of pykoticon will be ready.
Several minor fixes.

Location:
pykota/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2624 r2631  
    296296                    self.logdebug("Seen DENY command.") 
    297297                    action = "DENY" 
     298                elif line == "CANCEL" : 
     299                    self.logdebug("Seen CANCEL command.") 
     300                    action = "CANCEL" 
    298301                elif line.startswith("USERNAME=") :     
    299302                    username = line.split("=", 1)[1].strip() 
     
    307310             
    308311            # now overwrite the job's ticket if new data was supplied 
    309             if action : 
     312            if action == "DENY" : 
    310313                self.Action = action 
    311314                self.Reason = _("You are not allowed to print at this time.") 
     315            elif action == "CANCEL" : 
     316                self.Action = action 
     317                self.Reason = _("Print job cancelled.") 
    312318            if username : 
    313319                self.UserName = username 
     
    891897        self.exportPhaseInfo("BEFORE") 
    892898         
    893         if self.Action != "DENY" :  
     899        if self.Action not in ("DENY", "CANCEL") :  
    894900            if self.Printer.MaxJobSize and (self.softwareJobSize > self.Printer.MaxJobSize) : 
    895901                # This printer was set to refuse jobs this large. 
     
    900906                self.Reason = _("You are not allowed to print so many pages on printer %s at this time.") % self.PrinterName 
    901907             
    902         if self.Action != "DENY" : 
     908        if self.Action not in ("DENY", "CANCEL") : 
    903909            if self.User.LimitBy == "noprint" : 
    904910                self.printInfo(_("User %s is not allowed to print at this time.") % self.UserName, "warn") 
     
    906912                self.Reason = _("Your account settings forbid you to print at this time.") 
    907913                 
    908         if self.Action != "DENY" : 
     914        if self.Action not in ("DENY", "CANCEL") : 
    909915            # If printing is still allowed at this time, we 
    910916            # need to extract the billing code information from the database. 
     
    913919            self.getBillingCode() 
    914920             
    915         if self.Action != "DENY" : 
     921        if self.Action not in ("DENY", "CANCEL") : 
    916922            # If printing is still allowed at this time, we 
    917923            # need to check if the job is a dupe or not, and what to do then. 
     
    920926            self.checkIfDupe() 
    921927                     
    922         if self.Action != "DENY" : 
     928        if self.Action not in ("DENY", "CANCEL") : 
    923929            # If printing is still allowed at this time, we 
    924930            # need to check the user's print quota on the current printer. 
     
    962968        if self.Action == "DENY" : 
    963969            self.printInfo(_("Job denied, no accounting will be done.")) 
     970        elif self.Action == "CANCEL" :     
     971            self.printInfo(_("Job cancelled, no accounting will be done.")) 
    964972        else : 
    965973            self.printInfo(_("Job accounting begins.")) 
     
    990998        if self.Action == "DENY" : 
    991999            self.printInfo(_("Job denied, no accounting has been done.")) 
     1000        elif self.Action == "CANCEL" :     
     1001            self.printInfo(_("Job cancelled, no accounting has been done.")) 
    9921002        else : 
    9931003            self.deinstallSigTermHandler() 
     
    10201030                self.JobSize = 0 
    10211031                self.printInfo(_("Job size forced to 0 because printing is denied.")) 
     1032            elif self.Action == "CANCEL" :      
     1033                self.JobSize = 0 
     1034                self.printInfo(_("Job size forced to 0 because printing was cancelled.")) 
    10221035            else :     
    10231036                self.UserPQuota.resetDenyBannerCounter() 
     
    10281041            self.printInfo(_("Job size : %i") % self.JobSize) 
    10291042             
    1030             if (self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE") : 
     1043            if ((self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE")) or \ 
     1044                (self.Action in ("DENY", "CANCEL")) : 
    10311045                self.JobPrice = 0.0 
    10321046            elif (self.User.LimitBy == "nochange") or self.Printer.PassThrough : 
     
    10481062             
    10491063            if hasattr(self, "BillingCode") and self.BillingCode and self.BillingCode.Exists : 
    1050                 if (self.Action != "PROBLEM") or (onbackenderror == "CHARGE") : 
     1064                if (self.Action in ("ALLOW", "WARN")) or \ 
     1065                   ((self.Action == "PROBLEM") and (onbackenderror == "CHARGE")) : 
    10511066                    self.BillingCode.consume(self.JobSize, self.JobPrice) 
    10521067                    self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode) 
  • pykota/trunk/bin/pkbanner

    r2627 r2631  
    188188        elif action == "WARN" :     
    189189            action = _("Allowed with Warning") 
     190        elif action == "PROBLEM" :     
     191            # should never occur 
     192            action = _("Problem") 
     193        elif action == "CANCEL" :     
     194            # should never occur 
     195            action = _("Cancelled") 
    190196        ypos -= self.printVar(c, xcenter, ypos, _("Result"), action, 14, savetoner)  
    191197         
  • pykota/trunk/cgi-bin/printquota.cgi

    r2622 r2631  
    234234                        elif job.JobAction == "PROBLEM" : 
    235235                            oddevenclass = "problem" 
     236                        elif job.JobAction == "CANCEL" : 
     237                            oddevenclass = "cancel" 
    236238                        username_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "username" : job.UserName}), job.UserName) 
    237239                        printername_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "printername" : job.PrinterName}), job.PrinterName) 
  • pykota/trunk/conf/pykota.conf.sample

    r2622 r2631  
    346346# Should we launch a command to overwrite the job's ticket ? 
    347347# This allows a command to overwrite the username and/or the 
    348 # billing code used, or to deny the job. 
     348# billing code used, or to deny or cancel the job. 
    349349# If unset no command is launched and the job's username and 
    350350# billing code are used as they are received. 
     
    356356#    BILLINGCODE=the_billingcode_we_want_to_overwrite_with 
    357357#    DENY  
     358#    CANCEL 
    358359# 
    359360# NB : the output is entirely read, and the latest value 
     
    364365# If only BILLINGCODE= lines are printed, the username is 
    365366# used unchanged. 
    366 # If DENY is output, but is followed by new USERNAME= or 
    367 # BILLINGCODE= lines, the job is not denied. 
     367# If DENY or CANCEL is output, but is followed by new USERNAME= or 
     368# BILLINGCODE= lines, the job is not denied nor cancelled. 
    368369# 
    369370# This value can be set either globally or on a per printer basis 
     
    388389# If both are defined, the printer option has priority. 
    389390# 
     391# unknown_billingcode : deny 
     392# unknown_billingcode : deny(/path/to/some/script) 
    390393# unknown_billingcode : create 
    391394 
  • pykota/trunk/initscripts/ldap/pykota.schema

    r2585 r2631  
    104104# pykotaAction 
    105105attributetype ( 1.3.6.1.4.1.16868.1.1.14 NAME 'pykotaAction' 
    106         DESC 'Was the job allowed, denied, or failed : ( "ALLOW" |  "DENY" | "PROBLEM" )' 
     106        DESC 'Was the job allowed, denied, warned, cancelled or failed : ( "ALLOW" |  "DENY" | "WARN" | "CANCEL" | "PROBLEM" )' 
    107107        EQUALITY caseExactIA5Match 
    108108        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
  • pykota/trunk/NEWS

    r2627 r2631  
    2222PyKota NEWS : 
    2323        
     24    - 1.24alpha8 : 
     25     
     26        - Now subprocesses launched through the overwrite_jobticket directive 
     27          can also output 'CANCEL', to represent the user's own choice to 
     28          cancel the print job. 
     29           
    2430    - 1.24alpha7 : 
    2531      
  • pykota/trunk/pykota/version.py

    r2622 r2631  
    2222# 
    2323 
    24 __version__ = "1.24alpha7_unofficial" 
     24__version__ = "1.24alpha8_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS." 
  • pykota/trunk/stylesheets/pykota.css

    r2622 r2631  
    4444      } 
    4545       
     46.cancel {      
     47        background-color: #BEDBED; 
     48      } 
     49       
    4650.pykotacolsheader {       
    4751        background-color: #AAAAAA;