#! /usr/bin/python
# -*- coding: ISO-8859-15 -*-
# PyKota Print Quotes generator
#
# PyKota - Print Quotas for CUPS and LPRng
#
# (c) 2003, 2004, 2005 Jerome Alet
%s © %s %s
""" class PyKotMeGUI(PyKotaTool) : """PyKota Quote's Generator GUI""" def guiDisplay(self) : """Displays the administrative interface.""" global header, footer print header % (self.getCharset(), _("PyKota Quotes"), \ self.config.getLogoLink(), \ self.config.getLogoURL(), version.__version__, \ self.config.getLogoLink(), \ version.__version__, _("PyKota Quotes"), \ _("Quote")) print self.body print footer % (_("Quote"), version.__doc__, version.__years__, version.__author__) def error(self, message) : """Adds an error message to the GUI's body.""" if message : self.body = '%s
\n%s' % (message, self.body) def htmlListPrinters(self, selected=[], mask="*") : """Displays the printers multiple selection list.""" printers = self.storage.getMatchingPrinters(mask) selectednames = [p.Name for p in selected] message = '%s : |
%s
\n" % _("Please click on the above button") if self.form.has_key("report") : if self.form.has_key("printers") : printersfield = self.form["printers"] if type(printersfield) != type([]) : printersfield = [ printersfield ] printers = [self.storage.getPrinter(p.value) for p in printersfield] else : printers = self.storage.getMatchingPrinters("*") if self.form.has_key("inputfile") : inputfile = self.form["inputfile"].value if os.environ.get("REMOTE_USER") is not None : self.body += self.htmlListPrinters(printers or []) self.body += "%s
' % msg jobsize = 0 # unknown file format ? else : self.body += "%s
" % (_("Job size : %i pages") % jobsize) remuser = os.environ.get("REMOTE_USER") # special hack to accomodate mod_auth_ldap Apache module try : remuser = remuser.split("=")[1].split(",")[0] except : pass if not remuser : self.body += "%s
" % _("The exact cost of a print job can only be determined for a particular user. Please retry while logged-in.") else : try : user = self.storage.getUser(remuser) if user.Exists : if user.LimitBy == "noprint" : self.body += "%s
" % _("Your account settings forbid you to print at this time.") else : for printer in printers : upquota = self.storage.getUserPQuota(user, printer) if upquota.Exists : if printer.MaxJobSize and (jobsize > printer.MaxJobSize) : msg = _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name else : cost = upquota.computeJobPrice(jobsize) msg = _("Cost on printer %s : %.2f") % (printer.Name, cost) if printer.PassThrough : msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode")) elif user.LimitBy == "nochange" : msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable")) self.body += "%s
" % msg except : self.body += '%s
' % self.crashed("CGI Error").replace("\n", "