From: richard Date: Sun, 29 Jul 2001 08:27:40 +0000 (+0000) Subject: Fixed handling of passed-in values in form elements (ie. during a X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9d075945243097ff90aecb6874dc4a8b4999e18e;p=roundup.git Fixed handling of passed-in values in form elements (ie. during a drill-down) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@134 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index a30bc48..1c00040 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -1,4 +1,4 @@ -# $Id: cgi_client.py,v 1.7 2001-07-29 07:01:39 richard Exp $ +# $Id: cgi_client.py,v 1.8 2001-07-29 08:27:40 richard Exp $ import os, cgi, pprint, StringIO, urlparse, re, traceback @@ -105,22 +105,29 @@ class Client: def index_filterspec(self): ''' pull the index filter spec from the form + + Links and multilinks want to be lists - the rest are straight + strings. ''' - # all the other form args are filters + props = self.db.classes[self.classname].getprops() + # all the form args not starting with ':' are filters filterspec = {} for key in self.form.keys(): if key[0] == ':': continue + prop = props[key] value = self.form[key] - if type(value) == type([]): - value = [arg.value for arg in value] + if prop.isLinkType or prop.isMultilinkType: + if type(value) == type([]): + value = [arg.value for arg in value] + else: + value = value.value.split(',') + l = filterspec.get(key, []) + l = l + value + filterspec[key] = l else: - value = value.value.split(',') - l = filterspec.get(key, []) - l = l + value - filterspec[key] = l + filterspec[key] = value.value return filterspec - default_index_sort = ['-activity'] default_index_group = ['priority'] default_index_filter = [] @@ -496,6 +503,9 @@ class Client: # # $Log: not supported by cvs2svn $ +# Revision 1.7 2001/07/29 07:01:39 richard +# Added vim command to all source so that we don't get no steenkin' tabs :) +# # Revision 1.6 2001/07/29 04:04:00 richard # Moved some code around allowing for subclassing to change behaviour. # diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 036ad19..7d574fd 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -1,15 +1,16 @@ -# $Id: htmltemplate.py,v 1.8 2001-07-29 07:01:39 richard Exp $ +# $Id: htmltemplate.py,v 1.9 2001-07-29 08:27:40 richard Exp $ import os, re, StringIO, urllib, cgi, errno import hyperdb, date class Base: - def __init__(self, db, templates, classname, nodeid=None, form=None): + def __init__(self, db, templates, classname, nodeid=None, form=None, + filterspec=None): # TODO: really not happy with the way templates is passed on here self.db, self.templates = db, templates self.classname, self.nodeid = classname, nodeid - self.form = form + self.form, self.filterspec = form, filterspec self.cl = self.db.classes[self.classname] self.properties = self.cl.getprops() @@ -57,11 +58,16 @@ class Field(Base): to be edited ''' def __call__(self, property, size=None, height=None, showid=0): - if not self.nodeid and self.form is None: + if not self.nodeid and self.form and self.filterspec is None: return '[Field: not called from item]' propclass = self.properties[property] if self.nodeid: value = self.cl.get(self.nodeid, property) + elif self.filterspec is not None: + if propclass.isMultilinkType: + value = self.filterspec.get(property, []) + else: + value = self.filterspec.get(property, '') else: # TODO: pull the value from the form if propclass.isMultilinkType: value = [] @@ -265,6 +271,8 @@ class Checklist(Base): propclass = self.properties[property] if self.nodeid: value = self.cl.get(self.nodeid, property) + elif self.filterspec is not None: + value = self.filterspec.get(property, []) else: value = [] if propclass.isLinkType or propclass.isMultilinkType: @@ -273,7 +281,7 @@ class Checklist(Base): k = linkcl.labelprop() for optionid in linkcl.list(): option = linkcl.get(optionid, k) - if optionid in value: + if optionid in value or option in value: checked = 'checked' else: checked = '' @@ -405,22 +413,23 @@ def index(client, templates, db, classname, filterspec={}, filter=[], columns=[], sort=[], group=[], show_display_form=1, nodeids=None, col_re=re.compile(r']+)">')): globals = { - 'plain': Plain(db, templates, classname, form={}), - 'field': Field(db, templates, classname, form={}), - 'menu': Menu(db, templates, classname, form={}), - 'link': Link(db, templates, classname, form={}), - 'count': Count(db, templates, classname, form={}), - 'reldate': Reldate(db, templates, classname, form={}), - 'download': Download(db, templates, classname, form={}), - 'checklist': Checklist(db, templates, classname, form={}), - 'list': List(db, templates, classname, form={}), - 'history': History(db, templates, classname, form={}), - 'submit': Submit(db, templates, classname, form={}), - 'note': Note(db, templates, classname, form={}) + 'plain': Plain(db, templates, classname, filterspec=filterspec), + 'field': Field(db, templates, classname, filterspec=filterspec), + 'menu': Menu(db, templates, classname, filterspec=filterspec), + 'link': Link(db, templates, classname, filterspec=filterspec), + 'count': Count(db, templates, classname, filterspec=filterspec), + 'reldate': Reldate(db, templates, classname, filterspec=filterspec), + 'download': Download(db, templates, classname, filterspec=filterspec), + 'checklist': Checklist(db, templates, classname, filterspec=filterspec), + 'list': List(db, templates, classname, filterspec=filterspec), + 'history': History(db, templates, classname, filterspec=filterspec), + 'submit': Submit(db, templates, classname, filterspec=filterspec), + 'note': Note(db, templates, classname, filterspec=filterspec) } cl = db.classes[classname] properties = cl.getprops() w = client.write + w('
') try: template = open(os.path.join(templates, classname+'.filter')).read() @@ -431,28 +440,26 @@ def index(client, templates, db, classname, filterspec={}, filter=[], all_filters = [] if template and filter: # display the filter section - w('') w('') w('') w(' ') w('') replace = IndexTemplateReplace(globals, locals(), filter) w(replace.go(template)) - if columns: - w(''%','.join(columns)) - if filter: - w(''%','.join(filter)) - if sort: - w(''%','.join(sort)) - if group: - w(''%','.join(group)) - for k, v in filterspec.items(): - if type(v) == type([]): v = ','.join(v) - w(''%(k, v)) w('') w('') w('
Filter specification...
 
') - w('
') + + # If the filters aren't being displayed, then hide their current + # value in the form + if not filter: + for k, v in filterspec.items(): + if type(v) == type([]): v = ','.join(v) + w(''%(k, v)) + + # make sure that the sorting doesn't get lost either + if sort: + w(''%','.join(sort)) # XXX deviate from spec here ... # load the index section template and figure the default columns from it @@ -540,13 +547,8 @@ def index(client, templates, db, classname, filterspec={}, filter=[], return # now add in the filter/columns/group/etc config table form - w('

') + w('

') w('') - for k,v in filterspec.items(): - if type(v) == type([]): v = ','.join(v) - w(''%(k, v)) - if sort: - w(''%','.join(sort)) names = [] for name in cl.getprops().keys(): if name in all_filters or name in all_columns: @@ -707,6 +709,9 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.8 2001/07/29 07:01:39 richard +# Added vim command to all source so that we don't get no steenkin' tabs :) +# # Revision 1.7 2001/07/29 05:36:14 richard # Cleanup of the link label generation. # diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 4dd8364..bc1013f 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -1,4 +1,4 @@ -# $Id: hyperdb.py,v 1.7 2001-07-29 07:01:39 richard Exp $ +# $Id: hyperdb.py,v 1.8 2001-07-29 08:27:40 richard Exp $ # standard python modules import cPickle, re, string @@ -387,7 +387,7 @@ class Class: """Return the name of the key property for this class or None.""" return self.key - def labelprop(self, nodeid): + def labelprop(self): ''' Return the property name for a label for the given node. This method attempts to generate a consistent label for the node. @@ -551,7 +551,6 @@ class Class: u.append(entry) l.append((1, k, u)) elif propclass.isStringType: - v = v[0] if '*' in v or '?' in v: # simple glob searching v = v.replace('?', '.') @@ -789,6 +788,9 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.7 2001/07/29 07:01:39 richard +# Added vim command to all source so that we don't get no steenkin' tabs :) +# # Revision 1.6 2001/07/29 05:36:14 richard # Cleanup of the link label generation. #