Skip to content

Commit e00c4e4

Browse files
author
Richard Jones
committed
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.
1 parent d21bf14 commit e00c4e4

File tree

6 files changed

+68
-11
lines changed

6 files changed

+68
-11
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Feature:
1414
- access using the admin "class list" interface
1515
- limited to admin-only
1616
- requires the csv module from object-craft (url given if it's missing)
17+
. Added popup help for classes using the classhelp html template function.
18+
- add <display call="classhelp('priority', 'id,name,description')">
19+
to an item page, and it generates a link to a popup window which displays
20+
the id, name and description for the priority class. The description
21+
field won't exist in most installations, but it will be added to the
22+
default templates.
1723

1824
Fixed:
1925
. Clean up mail handling, multipart handling.

roundup/cgi_client.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.106 2002-02-21 06:23:00 richard Exp $
18+
# $Id: cgi_client.py,v 1.107 2002-02-21 06:57:38 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -52,11 +52,12 @@ def __init__(self, instance, request, env, form=None):
5252
self.env = env
5353
self.path = env['PATH_INFO']
5454
self.split_path = self.path.split('/')
55+
self.instance_path_name = env['INSTANCE_NAME']
5556
url = self.env['SCRIPT_NAME'] + '/'
5657
machine = self.env['SERVER_NAME']
5758
port = self.env['SERVER_PORT']
5859
if port != '80': machine = machine + ':' + port
59-
self.base = urlparse.urlunparse(('http', machine, url, None,None,None))
60+
self.base = urlparse.urlunparse(('http', env['HOST'], url, None,None,None))
6061

6162
if form is None:
6263
self.form = cgi.FieldStorage(environ=env)
@@ -96,10 +97,11 @@ def header(self, headers={'Content-Type':'text/html'}):
9697
submitted = true;
9798
return 1;
9899
}
100+
99101
function help_window(helpurl) {
100-
helpwin = window.open(%(base)s + helpurl, 'HelpWindow',
101-
'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
102+
HelpWin = window.open('%(base)s%(instance_path_name)s/' + helpurl, 'HelpWindow', 'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
102103
}
104+
103105
</script>
104106
'''
105107

@@ -396,6 +398,27 @@ def basicClassEditPage(self):
396398

397399
w(_('</textarea><br><input type="submit" value="Save Changes"></form>'))
398400

401+
def classhelp(self):
402+
'''Display a table of class info
403+
'''
404+
w = self.write
405+
cn = self.form['classname'].value
406+
cl = self.db.classes[cn]
407+
props = self.form['columns'].value.split(',')
408+
409+
w('<table border=1 cellspacing=0 cellpaddin=2>')
410+
w('<tr>')
411+
for name in props:
412+
w('<th align=left>%s</th>'%name)
413+
w('</tr>')
414+
for nodeid in cl.list():
415+
w('<tr>')
416+
for name in props:
417+
value = cgi.escape(str(cl.get(nodeid, name)))
418+
w('<td align="left" valign="top">%s</td>'%value)
419+
w('</tr>')
420+
w('</table>')
421+
399422
def shownode(self, message=None):
400423
''' display an item
401424
'''
@@ -1101,6 +1124,9 @@ def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
11011124
if action == 'list_classes':
11021125
self.classes()
11031126
return
1127+
if action == 'classhelp':
1128+
self.classhelp()
1129+
return
11041130
if action == 'login':
11051131
self.login()
11061132
return
@@ -1298,6 +1324,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
12981324

12991325
#
13001326
# $Log: not supported by cvs2svn $
1327+
# Revision 1.106 2002/02/21 06:23:00 richard
1328+
# *** empty log message ***
1329+
#
13011330
# Revision 1.105 2002/02/20 05:52:10 richard
13021331
# better error handling
13031332
#

roundup/htmltemplate.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.78 2002-02-21 06:23:00 richard Exp $
18+
# $Id: htmltemplate.py,v 1.79 2002-02-21 06:57:38 richard Exp $
1919

2020
__doc__ = """
2121
Template engine.
@@ -655,11 +655,11 @@ def do_submit(self):
655655
else:
656656
return _('[Submit: not called from item]')
657657

658-
def do_classhelp(self, classname, colums):
658+
def do_classhelp(self, classname, properties):
659659
'''pop up a javascript window with class help
660660
'''
661661
return '<a href="javascript:help_window(\'classhelp?classname=%s&' \
662-
'columns=%s\')"><b>(?)</b></a>'%(classname, columns)
662+
'properties=%s\')"><b>(?)</b></a>'%(classname, properties)
663663
#
664664
# INDEX TEMPLATES
665665
#
@@ -1081,6 +1081,9 @@ def render(self, form):
10811081

10821082
#
10831083
# $Log: not supported by cvs2svn $
1084+
# Revision 1.78 2002/02/21 06:23:00 richard
1085+
# *** empty log message ***
1086+
#
10841087
# Revision 1.77 2002/02/20 05:05:29 richard
10851088
# . Added simple editing for classes that don't define a templated interface.
10861089
# - access using the admin "class list" interface

roundup/scripts/roundup_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
""" HTTP Server that serves roundup.
2020
21-
$Id: roundup_server.py,v 1.2 2002-01-29 20:07:15 jhermann Exp $
21+
$Id: roundup_server.py,v 1.3 2002-02-21 06:57:39 richard Exp $
2222
"""
2323

2424
# python version check
@@ -158,6 +158,7 @@ def inner_run_cgi(self):
158158
env['SCRIPT_NAME'] = ''
159159
env['SERVER_NAME'] = self.server.server_name
160160
env['SERVER_PORT'] = str(self.server.server_port)
161+
env['HOST'] = self.headers['host']
161162

162163
decoded_query = query.replace('+', ' ')
163164

@@ -248,6 +249,9 @@ def run():
248249

249250
#
250251
# $Log: not supported by cvs2svn $
252+
# Revision 1.2 2002/01/29 20:07:15 jhermann
253+
# Conversion to generated script stubs
254+
#
251255
# Revision 1.1 2002/01/29 19:53:08 jhermann
252256
# Moved scripts from top-level dir to roundup.scripts subpackage
253257
#

test/test_dates.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: test_dates.py,v 1.8 2002-01-16 07:02:57 richard Exp $
18+
# $Id: test_dates.py,v 1.9 2002-02-21 06:57:39 richard Exp $
1919

2020
import unittest, time
2121

@@ -70,6 +70,8 @@ def testOffset(self):
7070
ae(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
7171
date = Date("8:47:11", -5)
7272
ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
73+
# TODO: assert something
74+
Date() + Interval('- 2y 2m')
7375

7476
def testInterval(self):
7577
ae = self.assertEqual
@@ -87,6 +89,10 @@ def suite():
8789

8890
#
8991
# $Log: not supported by cvs2svn $
92+
# Revision 1.8 2002/01/16 07:02:57 richard
93+
# . lots of date/interval related changes:
94+
# - more relaxed date format for input
95+
#
9096
# Revision 1.7 2001/08/13 23:01:53 richard
9197
# fixed a 2.1-ism
9298
#

test/test_htmltemplate.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_htmltemplate.py,v 1.9 2002-02-15 07:08:45 richard Exp $
11+
# $Id: test_htmltemplate.py,v 1.10 2002-02-21 06:57:39 richard Exp $
1212

1313
import unittest, cgi, time
1414

@@ -24,7 +24,7 @@ def get(self, nodeid, attribute, default=None):
2424
elif attribute == 'filename':
2525
return 'file.foo'
2626
elif attribute == 'date':
27-
return date.Date('2000-01-01')
27+
return date.Date() + date.Interval('- 2y 2m')
2828
elif attribute == 'interval':
2929
return date.Interval('-3d')
3030
elif attribute == 'link':
@@ -330,12 +330,21 @@ def testList_multilink(self):
330330
#self.assertEqual(self.tf.do_list('multilink'),'')
331331
pass
332332

333+
def testClasshelp(self):
334+
self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'),
335+
'<a href="javascript:help_window(\'classhelp?classname=theclass'
336+
'&properties=prop1,prop2\')"><b>(?)</b></a>')
337+
333338
def suite():
334339
return unittest.makeSuite(NodeCase, 'test')
335340

336341

337342
#
338343
# $Log: not supported by cvs2svn $
344+
# Revision 1.9 2002/02/15 07:08:45 richard
345+
# . Alternate email addresses are now available for users. See the MIGRATION
346+
# file for info on how to activate the feature.
347+
#
339348
# Revision 1.8 2002/02/06 03:47:16 richard
340349
# . #511586 ] unittest FAIL: testReldate_date
341350
#

0 commit comments

Comments
 (0)