changeset 635:3d61b5d2243e

Added popup help for classes using the classhelp html template function. - add <display call="classhelp('priority', 'id,name,description')"> to an item page, and it generates a link to a popup window which displays the id, name and description for the priority class. The description field won't exist in most installations, but it will be added to the default templates.
author Richard Jones <richard@users.sourceforge.net>
date Thu, 21 Feb 2002 06:57:39 +0000
parents 53549c6a7b33
children 3569dfce4bc5
files CHANGES.txt roundup/cgi_client.py roundup/htmltemplate.py roundup/scripts/roundup_server.py test/test_dates.py test/test_htmltemplate.py
diffstat 6 files changed, 68 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Thu Feb 21 06:23:00 2002 +0000
+++ b/CHANGES.txt	Thu Feb 21 06:57:39 2002 +0000
@@ -14,6 +14,12 @@
    - access using the admin "class list" interface
    - limited to admin-only
    - requires the csv module from object-craft (url given if it's missing)
+ . Added popup help for classes using the classhelp html template function.
+   - add <display call="classhelp('priority', 'id,name,description')">
+     to an item page, and it generates a link to a popup window which displays
+     the id, name and description for the priority class. The description
+     field won't exist in most installations, but it will be added to the
+     default templates.
 
 Fixed:
  . Clean up mail handling, multipart handling.
--- a/roundup/cgi_client.py	Thu Feb 21 06:23:00 2002 +0000
+++ b/roundup/cgi_client.py	Thu Feb 21 06:57:39 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: cgi_client.py,v 1.106 2002-02-21 06:23:00 richard Exp $
+# $Id: cgi_client.py,v 1.107 2002-02-21 06:57:38 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -52,11 +52,12 @@
         self.env = env
         self.path = env['PATH_INFO']
         self.split_path = self.path.split('/')
+        self.instance_path_name = env['INSTANCE_NAME']
         url = self.env['SCRIPT_NAME'] + '/'
         machine = self.env['SERVER_NAME']
         port = self.env['SERVER_PORT']
         if port != '80': machine = machine + ':' + port
-        self.base = urlparse.urlunparse(('http', machine, url, None,None,None))
+        self.base = urlparse.urlunparse(('http', env['HOST'], url, None,None,None))
 
         if form is None:
             self.form = cgi.FieldStorage(environ=env)
@@ -96,10 +97,11 @@
     submitted = true;
     return 1;
 }
+
 function help_window(helpurl) {
-    helpwin = window.open(%(base)s + helpurl, 'HelpWindow',
-       'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
+    HelpWin = window.open('%(base)s%(instance_path_name)s/' + helpurl, 'HelpWindow', 'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
 }
+
 </script>
 '''
 
@@ -396,6 +398,27 @@
 
         w(_('</textarea><br><input type="submit" value="Save Changes"></form>'))
 
+    def classhelp(self):
+        '''Display a table of class info
+        '''
+        w = self.write
+        cn = self.form['classname'].value
+        cl = self.db.classes[cn]
+        props = self.form['columns'].value.split(',')
+
+        w('<table border=1 cellspacing=0 cellpaddin=2>')
+        w('<tr>')
+        for name in props:
+            w('<th align=left>%s</th>'%name)
+        w('</tr>')
+        for nodeid in cl.list():
+            w('<tr>')
+            for name in props:
+                value = cgi.escape(str(cl.get(nodeid, name)))
+                w('<td align="left" valign="top">%s</td>'%value)
+            w('</tr>')
+        w('</table>')
+
     def shownode(self, message=None):
         ''' display an item
         '''
@@ -1101,6 +1124,9 @@
         if action == 'list_classes':
             self.classes()
             return
+        if action == 'classhelp':
+            self.classhelp()
+            return
         if action == 'login':
             self.login()
             return
@@ -1298,6 +1324,9 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.106  2002/02/21 06:23:00  richard
+# *** empty log message ***
+#
 # Revision 1.105  2002/02/20 05:52:10  richard
 # better error handling
 #
--- a/roundup/htmltemplate.py	Thu Feb 21 06:23:00 2002 +0000
+++ b/roundup/htmltemplate.py	Thu Feb 21 06:57:39 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: htmltemplate.py,v 1.78 2002-02-21 06:23:00 richard Exp $
+# $Id: htmltemplate.py,v 1.79 2002-02-21 06:57:38 richard Exp $
 
 __doc__ = """
 Template engine.
@@ -655,11 +655,11 @@
         else:
             return _('[Submit: not called from item]')
 
-    def do_classhelp(self, classname, colums):
+    def do_classhelp(self, classname, properties):
         '''pop up a javascript window with class help
         '''
         return '<a href="javascript:help_window(\'classhelp?classname=%s&' \
-            'columns=%s\')"><b>(?)</b></a>'%(classname, columns)
+            'properties=%s\')"><b>(?)</b></a>'%(classname, properties)
 #
 #   INDEX TEMPLATES
 #
@@ -1081,6 +1081,9 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.78  2002/02/21 06:23:00  richard
+# *** empty log message ***
+#
 # Revision 1.77  2002/02/20 05:05:29  richard
 #  . Added simple editing for classes that don't define a templated interface.
 #    - access using the admin "class list" interface
--- a/roundup/scripts/roundup_server.py	Thu Feb 21 06:23:00 2002 +0000
+++ b/roundup/scripts/roundup_server.py	Thu Feb 21 06:57:39 2002 +0000
@@ -18,7 +18,7 @@
 # 
 """ HTTP Server that serves roundup.
 
-$Id: roundup_server.py,v 1.2 2002-01-29 20:07:15 jhermann Exp $
+$Id: roundup_server.py,v 1.3 2002-02-21 06:57:39 richard Exp $
 """
 
 # python version check
@@ -158,6 +158,7 @@
         env['SCRIPT_NAME'] = ''
         env['SERVER_NAME'] = self.server.server_name
         env['SERVER_PORT'] = str(self.server.server_port)
+        env['HOST'] = self.headers['host']
 
         decoded_query = query.replace('+', ' ')
 
@@ -248,6 +249,9 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.2  2002/01/29 20:07:15  jhermann
+# Conversion to generated script stubs
+#
 # Revision 1.1  2002/01/29 19:53:08  jhermann
 # Moved scripts from top-level dir to roundup.scripts subpackage
 #
--- a/test/test_dates.py	Thu Feb 21 06:23:00 2002 +0000
+++ b/test/test_dates.py	Thu Feb 21 06:57:39 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: test_dates.py,v 1.8 2002-01-16 07:02:57 richard Exp $ 
+# $Id: test_dates.py,v 1.9 2002-02-21 06:57:39 richard Exp $ 
 
 import unittest, time
 
@@ -70,6 +70,8 @@
         ae(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
         date = Date("8:47:11", -5)
         ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
+        # TODO: assert something
+        Date() + Interval('- 2y 2m')
 
     def testInterval(self):
         ae = self.assertEqual
@@ -87,6 +89,10 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.8  2002/01/16 07:02:57  richard
+#  . lots of date/interval related changes:
+#    - more relaxed date format for input
+#
 # Revision 1.7  2001/08/13 23:01:53  richard
 # fixed a 2.1-ism
 #
--- a/test/test_htmltemplate.py	Thu Feb 21 06:23:00 2002 +0000
+++ b/test/test_htmltemplate.py	Thu Feb 21 06:57:39 2002 +0000
@@ -8,7 +8,7 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_htmltemplate.py,v 1.9 2002-02-15 07:08:45 richard Exp $ 
+# $Id: test_htmltemplate.py,v 1.10 2002-02-21 06:57:39 richard Exp $ 
 
 import unittest, cgi, time
 
@@ -24,7 +24,7 @@
         elif attribute == 'filename':
             return 'file.foo'
         elif attribute == 'date':
-            return date.Date('2000-01-01')
+            return date.Date() + date.Interval('- 2y 2m')
         elif attribute == 'interval':
             return date.Interval('-3d')
         elif attribute == 'link':
@@ -330,12 +330,21 @@
         #self.assertEqual(self.tf.do_list('multilink'),'')
         pass
 
+    def testClasshelp(self):
+        self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'),
+            '<a href="javascript:help_window(\'classhelp?classname=theclass'
+            '&properties=prop1,prop2\')"><b>(?)</b></a>')
+
 def suite():
    return unittest.makeSuite(NodeCase, 'test')
 
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.9  2002/02/15 07:08:45  richard
+#  . Alternate email addresses are now available for users. See the MIGRATION
+#    file for info on how to activate the feature.
+#
 # Revision 1.8  2002/02/06 03:47:16  richard
 #  . #511586 ] unittest FAIL: testReldate_date
 #

Roundup Issue Tracker: http://roundup-tracker.org/