#! /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", "root") # special hack to accomodate mod_auth_ldap Apache module try : remuser = remuser.split("=")[1].split(",")[0] except IndexError : pass if remuser == "root" : 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 : for printer in printers : upquota = self.storage.getUserPQuota(user, printer) if upquota.Exists : cost = upquota.computeJobPrice(jobsize) self.body += "%s
" % (_("Cost on printer %s : %.2f") % (printer.Name, cost)) except : self.body += '%s
' % self.crashed("CGI Error").replace("\n", "