root / pykota / trunk / cgi-bin / pykotadmin.cgi @ 1258

Revision 1110, 3.9 kB (checked in by jalet, 21 years ago)

Cleanly deactivate pykotadmin.cgi

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#! /usr/bin/env python
2
3# PyKota - Print Quotas for CUPS and LPRng
4#
5# (c) 2003 Jerome Alet <alet@librelogiciel.com>
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19#
20# $Id$
21#
22# $Log$
23# Revision 1.2  2003/07/28 21:16:24  jalet
24# Cleanly deactivate pykotadmin.cgi
25#
26# Revision 1.1  2003/05/03 17:33:08  jalet
27# First shot at the complete web-based administrative interface.
28#
29#
30#
31
32import sys
33import os
34import cgi
35from pykota.tool import PyKotaTool, PyKotaToolError
36
37header = """Content-type: text/html
38
39<?xml version="1.0" encoding="iso-8859-1"?>
40<html>
41  <head>
42    <title>PyKota Administration</title>
43  </head>
44  <body>
45    <form action="pykotadmin.cgi" method="POST">
46      <table>
47        <tr>
48          <td>
49            <p>
50              <a href="http://www.librelogiciel.com/software/"><img src="http://www.librelogiciel.com/software/PyKota/calllogo" alt="PyKota's Logo" /></a>
51              <br />
52              <a href="http://www.librelogiciel.com/software/">PyKota</a>
53            </p>
54          </td>
55          <td colspan="2">
56            <h2>PyKota Administration</h2>
57          </td>
58        </tr>
59        <tr>
60          <td>
61            <input type="submit" name="action" value="Report" />
62          </td>
63          <td>
64            <input type="submit" name="action" value="Modify" />
65          </td>
66          <td>
67            <input type="submit" name="action" value="Warn" />
68          </td>
69        </tr>
70      </table>"""
71   
72footer = """
73    </form>
74  </body>
75</html>""" 
76
77
78class PyKotaAdminGUI(PyKotaTool) :
79    """PyKota Administrative GUI"""
80    def guiDisplay(self) :
81        """Displays the administrative interface."""
82        global header, footer
83        print header
84        print self.body
85        print footer
86       
87    def error(self, message) :
88        """Adds an error message to the GUI's body."""
89        if message :
90            self.body = '<p><font color="red">%s</font></p>\n%s' % (message, self.body)
91       
92    def htmlListPrinters(self) :   
93        """Displays the printers multiple selection list."""
94        printers = self.storage.getMatchingPrinters("*")
95        message = 'Printer : <select name="printers" multiple="multiple">'
96        for (printerid, printername) in printers :
97            message += '<option value="%s">%s</option>' % (printerid, printername)
98        message += '</select>'
99        return message
100       
101    def guiAction(self) :
102        """Main function"""
103        self.body = "<p>Please click on the menu above</p>\n"
104        form = cgi.FieldStorage()
105        if form.has_key("action") :
106            action = form["action"].value
107            if action == "Modify" :
108                self.error("Not implemented yet ! Sorry.")
109            elif action == "Warn" :
110                self.error("Not implemented yet ! Sorry.")
111            elif action == "Report" :
112                self.error("Not implemented yet ! Sorry.")
113            else :
114                self.error(body, "Invalid action [%s]" % action)
115        self.body = self.body + self.htmlListPrinters()           
116   
117if __name__ == "__main__" :
118    #admin = PyKotaAdminGUI()
119    #admin.guiAction()
120    #admin.guiDisplay()
121    print "Content-type: text/html\n\n<html><head><title>PyKotAdmin.cgi</title></head><body>This program is actually a draft. Don't use it !</body></html>"
Note: See TracBrowser for help on using the browser.