Skip to content

Commit 005c44c

Browse files
author
Richard Jones
committed
CGI interface view customisation section may now be hidden
(patch from Roch'e Compaan.)
1 parent b274517 commit 005c44c

File tree

3 files changed

+127
-78
lines changed

3 files changed

+127
-78
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ are given with the most recent entry first.
44
2001-10-?? - 0.3.0
55
Feature:
66
. Hyperdatabase sorts strings-that-look-like-numbers as numbers now.
7+
. CGI interface view customisation section may now be hidden (patch from
8+
Roch'e Compaan.)
79
Admin Tool (roundup-admin):
810
. Interactive mode for running multiple (independant at present) commands.
911
. Tabular display of nodes.

roundup/cgi_client.py

Lines changed: 31 additions & 9 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.34 2001-10-20 11:58:48 richard Exp $
18+
# $Id: cgi_client.py,v 1.35 2001-10-21 00:17:54 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121
import base64, Cookie, time
@@ -156,6 +156,21 @@ def index_filterspec(self):
156156
filterspec[key] = value.value
157157
return filterspec
158158

159+
def customization_widget(self):
160+
''' The customization widget is visible by default. The widget
161+
visibility is remembered by show_customization. Visibility
162+
is not toggled if the action value is "Redisplay"
163+
'''
164+
if not self.form.has_key('show_customization'):
165+
visible = 1
166+
else:
167+
visible = int(self.form['show_customization'].value)
168+
if self.form.has_key('action'):
169+
if self.form['action'].value != 'Redisplay':
170+
visible = self.form['action'].value == '+'
171+
172+
return visible
173+
159174
default_index_sort = ['-activity']
160175
default_index_group = ['priority']
161176
default_index_filter = []
@@ -182,7 +197,7 @@ def index(self):
182197
# XXX deviates from spec - loses the '+' (that's a reserved character
183198
# in URLS
184199
def list(self, sort=None, group=None, filter=None, columns=None,
185-
filterspec=None):
200+
filterspec=None, show_customization=None):
186201
''' call the template index with the args
187202
188203
:sort - sort by prop name, optionally preceeded with '-'
@@ -202,9 +217,12 @@ def list(self, sort=None, group=None, filter=None, columns=None,
202217
if filter is None: filter = self.index_arg(':filter')
203218
if columns is None: columns = self.index_arg(':columns')
204219
if filterspec is None: filterspec = self.index_filterspec()
220+
if show_customization is None:
221+
show_customization = self.customization_widget()
205222

206223
htmltemplate.index(self, self.TEMPLATES, self.db, cn, filterspec,
207-
filter, columns, sort, group)
224+
filter, columns, sort, group,
225+
show_customization=show_customization)
208226
self.pagefoot()
209227

210228
def shownode(self, message=None):
@@ -681,8 +699,8 @@ def pagehead(self, title, message=None):
681699
if self.user not in (None, 'anonymous'):
682700
userid = self.db.user.lookup(self.user)
683701
user_info = '''
684-
<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">My Issues</a> |
685-
<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">My Support</a> |
702+
<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> |
703+
<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">My Support</a> |
686704
<a href="user%s">My Details</a> | <a href="logout">Logout</a>
687705
'''%(userid, userid, userid)
688706
else:
@@ -707,11 +725,11 @@ def pagehead(self, title, message=None):
707725
<td align=right valign=bottom>%s</td></tr>
708726
<tr class="location-bar">
709727
<td align=left>All
710-
<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
711-
<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
728+
<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
729+
<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
712730
| Unassigned
713-
<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
714-
<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
731+
<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
732+
<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
715733
%s
716734
%s</td>
717735
<td align=right>%s</td>
@@ -776,6 +794,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
776794

777795
#
778796
# $Log: not supported by cvs2svn $
797+
# Revision 1.34 2001/10/20 11:58:48 richard
798+
# Catch errors in login - no username or password supplied.
799+
# Fixed editing of password (Password property type) thanks Roch'e Compaan.
800+
#
779801
# Revision 1.33 2001/10/17 00:18:41 richard
780802
# Manually constructing cookie headers now.
781803
#

roundup/htmltemplate.py

Lines changed: 94 additions & 69 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.28 2001-10-21 00:00:16 richard Exp $
18+
# $Id: htmltemplate.py,v 1.29 2001-10-21 00:17:56 richard Exp $
1919

2020
import os, re, StringIO, urllib, cgi, errno
2121

@@ -312,7 +312,7 @@ def __call__(self, property, **args):
312312
# get our current checkbox state
313313
if self.nodeid:
314314
# get the info from the node - make sure it's a list
315-
if isinstance(propclass, hyperdb.Link:
315+
if isinstance(propclass, hyperdb.Link):
316316
value = [self.cl.get(self.nodeid, property)]
317317
else:
318318
value = self.cl.get(self.nodeid, property)
@@ -462,6 +462,7 @@ def sortby(sort_name, columns, filter, sort, group, filterspec):
462462

463463
def index(client, templates, db, classname, filterspec={}, filter=[],
464464
columns=[], sort=[], group=[], show_display_form=1, nodeids=None,
465+
show_customization=1,
465466
col_re=re.compile(r'<property\s+name="([^>]+)">')):
466467
globals = {
467468
'plain': Plain(db, templates, classname, filterspec=filterspec),
@@ -498,7 +499,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
498499
replace = IndexTemplateReplace(globals, locals(), filter)
499500
w(replace.go(template))
500501
w('<tr class="location-bar"><td width="1%%">&nbsp;</td>')
501-
w('<td><input type="submit" value="Redisplay"></td></tr>')
502+
w('<td><input type="submit" name="action" value="Redisplay"></td></tr>')
502503
w('</table>')
503504

504505
# If the filters aren't being displayed, then hide their current
@@ -528,6 +529,93 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
528529
l.append(name)
529530
columns = l
530531

532+
# now add in the filter/columns/group/etc config table form
533+
w('<input type="hidden" name="show_customization" value="%s">' %
534+
show_customization )
535+
w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
536+
names = []
537+
for name in cl.getprops().keys():
538+
if name in all_filters or name in all_columns:
539+
names.append(name)
540+
w('<tr class="location-bar">')
541+
if show_customization:
542+
action = '-'
543+
else:
544+
action = '+'
545+
# hide the values for filters, columns and grouping in the form
546+
# if the customization widget is not visible
547+
for name in names:
548+
if all_filters and name in filter:
549+
w('<input type="hidden" name=":filter" value="%s">' % name)
550+
if all_columns and name in columns:
551+
w('<input type="hidden" name=":columns" value="%s">' % name)
552+
if all_columns and name in group:
553+
w('<input type="hidden" name=":group" value="%s">' % name)
554+
555+
if show_display_form:
556+
# TODO: The widget style can go into the stylesheet
557+
w('<th align="left" colspan=%s>'
558+
'<input style="height : 1em; width : 1em; font-size: 12pt" type="submit" name="action" value="%s">&nbsp;View '
559+
'customisation...</th></tr>\n'%(len(names)+1, action))
560+
if show_customization:
561+
w('<tr class="location-bar"><th>&nbsp;</th>')
562+
for name in names:
563+
w('<th>%s</th>'%name.capitalize())
564+
w('</tr>\n')
565+
566+
# Filter
567+
if all_filters:
568+
w('<tr><th width="1%" align=right class="location-bar">'
569+
'Filters</th>\n')
570+
for name in names:
571+
if name not in all_filters:
572+
w('<td>&nbsp;</td>')
573+
continue
574+
if name in filter: checked=' checked'
575+
else: checked=''
576+
w('<td align=middle>\n')
577+
w(' <input type="checkbox" name=":filter" value="%s" '
578+
'%s></td>\n'%(name, checked))
579+
w('</tr>\n')
580+
581+
# Columns
582+
if all_columns:
583+
w('<tr><th width="1%" align=right class="location-bar">'
584+
'Columns</th>\n')
585+
for name in names:
586+
if name not in all_columns:
587+
w('<td>&nbsp;</td>')
588+
continue
589+
if name in columns: checked=' checked'
590+
else: checked=''
591+
w('<td align=middle>\n')
592+
w(' <input type="checkbox" name=":columns" value="%s"'
593+
'%s></td>\n'%(name, checked))
594+
w('</tr>\n')
595+
596+
# Grouping
597+
w('<tr><th width="1%" align=right class="location-bar">'
598+
'Grouping</th>\n')
599+
for name in names:
600+
prop = properties[name]
601+
if name not in all_columns:
602+
w('<td>&nbsp;</td>')
603+
continue
604+
if name in group: checked=' checked'
605+
else: checked=''
606+
w('<td align=middle>\n')
607+
w(' <input type="checkbox" name=":group" value="%s"'
608+
'%s></td>\n'%(name, checked))
609+
w('</tr>\n')
610+
611+
w('<tr class="location-bar"><td width="1%">&nbsp;</td>')
612+
w('<td colspan="%s">'%len(names))
613+
w('<input type="submit" name="action" value="Redisplay"></td>')
614+
w('</tr>\n')
615+
616+
w('</table>\n')
617+
w('</form>\n')
618+
531619
# now display the index section
532620
w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
533621
w('<tr class="list-header">\n')
@@ -596,72 +684,6 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
596684

597685
w('</table>')
598686

599-
if not show_display_form:
600-
return
601-
602-
# now add in the filter/columns/group/etc config table form
603-
w('<p>')
604-
w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
605-
names = []
606-
for name in cl.getprops().keys():
607-
if name in all_filters or name in all_columns:
608-
names.append(name)
609-
w('<tr class="location-bar">')
610-
w('<th align="left" colspan=%s>View customisation...</th></tr>\n'%
611-
(len(names)+1))
612-
w('<tr class="location-bar"><th>&nbsp;</th>')
613-
for name in names:
614-
w('<th>%s</th>'%name.capitalize())
615-
w('</tr>\n')
616-
617-
# filter
618-
if all_filters:
619-
w('<tr><th width="1%" align=right class="location-bar">Filters</th>\n')
620-
for name in names:
621-
if name not in all_filters:
622-
w('<td>&nbsp;</td>')
623-
continue
624-
if name in filter: checked=' checked'
625-
else: checked=''
626-
w('<td align=middle>\n')
627-
w(' <input type="checkbox" name=":filter" value="%s" %s></td>\n'%(
628-
name, checked))
629-
w('</tr>\n')
630-
631-
# columns
632-
if all_columns:
633-
w('<tr><th width="1%" align=right class="location-bar">Columns</th>\n')
634-
for name in names:
635-
if name not in all_columns:
636-
w('<td>&nbsp;</td>')
637-
continue
638-
if name in columns: checked=' checked'
639-
else: checked=''
640-
w('<td align=middle>\n')
641-
w(' <input type="checkbox" name=":columns" value="%s" %s></td>\n'%(
642-
name, checked))
643-
w('</tr>\n')
644-
645-
# group
646-
w('<tr><th width="1%" align=right class="location-bar">Grouping</th>\n')
647-
for name in names:
648-
prop = properties[name]
649-
if name not in all_columns:
650-
w('<td>&nbsp;</td>')
651-
continue
652-
if name in group: checked=' checked'
653-
else: checked=''
654-
w('<td align=middle>\n')
655-
w(' <input type="checkbox" name=":group" value="%s" %s></td>\n'%(
656-
name, checked))
657-
w('</tr>\n')
658-
659-
w('<tr class="location-bar"><td width="1%">&nbsp;</td>')
660-
w('<td colspan="%s">'%len(names))
661-
w('<input type="submit" value="Redisplay"></td></tr>\n')
662-
w('</table>\n')
663-
w('</form>\n')
664-
665687

666688
#
667689
# ITEM TEMPLATES
@@ -768,6 +790,9 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
768790

769791
#
770792
# $Log: not supported by cvs2svn $
793+
# Revision 1.28 2001/10/21 00:00:16 richard
794+
# Fixed Checklist function - wasn't always working on a list.
795+
#
771796
# Revision 1.27 2001/10/20 12:13:44 richard
772797
# Fixed grouping of non-str properties (thanks Roch'e Compaan)
773798
#

0 commit comments

Comments
 (0)