From: gmcm Date: Wed, 31 Jul 2002 22:40:50 +0000 (+0000) Subject: Fixes to the search form and saving queries. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b844e3633e691a3a4825958507c1d9950c323934;p=roundup.git Fixes to the search form and saving queries. Fixes to sorting in back_metakit.py. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@942 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/backends/back_metakit.py b/roundup/backends/back_metakit.py index 7d173c1..46d82ea 100755 --- a/roundup/backends/back_metakit.py +++ b/roundup/backends/back_metakit.py @@ -46,6 +46,8 @@ class _Database(hyperdb.Database): except KeyError: x = 0 return x + elif classname == 'transactions': + return self.dirty return self.getclass(classname) def getclass(self, classname): return self.classes[classname] @@ -479,10 +481,11 @@ class Class: row._isdel = 1 if self.do_journal: self.db.addjournal(self.classname, nodeid, _RETIRE, {}) - iv = self.getindexview(1) - ndx = iv.find(k=getattr(row, self.keyname),i=row.id) - if ndx > -1: - iv.delete(ndx) + if self.keyname: + iv = self.getindexview(1) + ndx = iv.find(k=getattr(row, self.keyname),i=row.id) + if ndx > -1: + iv.delete(ndx) self.db.dirty = 1 self.fireReactors('retire', nodeid, None) def history(self, nodeid): @@ -732,7 +735,24 @@ class Class: try: prop = getattr(v, propname) except AttributeError: + print "MK has no property %s" % propname continue + propclass = self.ruprops.get(propname, None) + if propclass is None: + propclass = self.privateprops.get(propname, None) + if propclass is None: + print "Schema has no property %s" % propname + continue + if isinstance(propclass, hyperdb.Link): + linkclass = self.db.getclass(propclass.classname) + lv = linkclass.getview() + lv = lv.rename('id', propname) + v = v.join(lv, prop, 1) + if linkclass.getprops().has_key('order'): + propname = 'order' + else: + propname = linkclass.labelprop() + prop = getattr(v, propname) if isreversed: rev.append(prop) sortspec.append(prop) diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index b24f0fd..b5da415 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -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.152 2002-07-31 22:04:14 richard Exp $ +# $Id: cgi_client.py,v 1.153 2002-07-31 22:40:50 gmcm Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -764,6 +764,7 @@ function help_window(helpurl, width, height) { filterspec = self.index_filterspec(filter, queries.get(self.nodeid, 'klass')) if self.form.has_key('search_text'): search_text = self.form['search_text'].value + search_text = urllib.quote(search_text) else: search_text = '' if self.form.has_key(':pagesize'): @@ -782,15 +783,9 @@ function help_window(helpurl, width, height) { url += '&:pagesize=%s' % pagesize if search_text: url += '&search_text=%s' % search_text - qname = self.form['name'].value - chgd = [] - if qname != queries.get(self.nodeid, 'name'): - chgd.append('name') if url != queries.get(self.nodeid, 'url'): - chgd.append('url') - if chgd: - queries.set(self.nodeid, name=qname, url=url) - message = _('%(changes)s edited ok')%{'changes': ', '.join(chgd)} + queries.set(self.nodeid, url=url) + message = _('url edited ok') else: message = _('nothing changed') else: @@ -1357,7 +1352,7 @@ function help_window(helpurl, width, height) { # re-open the database for real, using the user self.opendb(self.user) password = cl.get(uid, 'password') - self.set_cookie(self.user, self.form['password'].value) + self.set_cookie(self.user, password) return 1 def set_cookie(self, user, password): @@ -1696,6 +1691,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): # # $Log: not supported by cvs2svn $ +# Revision 1.152 2002/07/31 22:04:14 richard +# cleanup +# # Revision 1.151 2002/07/30 21:37:43 richard # oops, thanks Duncan Booth for spotting this one # diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 6ad188b..4fd620b 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.107 2002-07-30 05:27:30 richard Exp $ +# $Id: htmltemplate.py,v 1.108 2002-07-31 22:40:50 gmcm Exp $ __doc__ = """ Template engine. @@ -832,13 +832,15 @@ class TemplateFunctions: for k,v in query.items(): query[k] = v[0].split(',') pagesize = query.get(':pagesize',['25'])[0] + search_text = query.get('search_text', [''])[0] + search_text = urllib.unquote(search_text) for k,v in query.items(): if k[0] != ':': filterspec[k] = v ixtmplt = IndexTemplate(self.client, self.templates, classname) qform = '
\n'%( self.classname,self.nodeid) - qform += ixtmplt.filter_form(query.get('search_text', ''), + qform += ixtmplt.filter_form(search_text, query.get(':filter', []), query.get(':columns', []), query.get(':group', []), @@ -931,6 +933,10 @@ class IndexTemplate(TemplateFunctions): def buildurl(self, filterspec, search_text, filter, columns, sort, group, pagesize): d = {'pagesize':pagesize, 'pagesize':pagesize, 'classname':self.classname} + if search_text: + d['searchtext'] = 'search_text=%s&' % search_text + else: + d['searchtext'] = '' d['filter'] = ','.join(map(urllib.quote,filter)) d['columns'] = ','.join(map(urllib.quote,columns)) d['sort'] = ','.join(map(urllib.quote,sort)) @@ -940,7 +946,7 @@ class IndexTemplate(TemplateFunctions): vals = ','.join(map(urllib.quote,vals)) tmp.append('%s=%s' % (col, vals)) d['filters'] = '&'.join(tmp) - return '%(classname)s?%(filters)s&:sort=%(sort)s&:filter=%(filter)s&:group=%(group)s&:columns=%(columns)s&:pagesize=%(pagesize)s' % d + return '%(classname)s?%(searchtext)s%(filters)s&:sort=%(sort)s&:filter=%(filter)s&:group=%(group)s&:columns=%(columns)s&:pagesize=%(pagesize)s' % d col_re=re.compile(r']+)">') def render(self, filterspec={}, search_text='', filter=[], columns=[], @@ -989,8 +995,8 @@ class IndexTemplate(TemplateFunctions): for name in columns: cname = name.capitalize() if show_display_form: - sb = self.sortby(name, filterspec, columns, filter, group, - sort, pagesize, startwith) + sb = self.sortby(name, search_text, filterspec, columns, filter, + group, sort, pagesize) anchor = "%s?%s"%(self.classname, sb) w('%s' '\n'%(anchor, cname)) @@ -1286,13 +1292,15 @@ class IndexTemplate(TemplateFunctions): w(' \n') w('\n') - def sortby(self, sort_name, filterspec, columns, filter, group, sort, - pagesize, startwith): + def sortby(self, sort_name, search_text, filterspec, columns, filter, group, sort, + pagesize): ''' Figure the link for a column heading so we can sort by that column ''' l = [] w = l.append + if search_text: + w('search_text=%s' % search_text) for k, v in filterspec.items(): k = urllib.quote(k) if type(v) == type([]): @@ -1306,7 +1314,7 @@ class IndexTemplate(TemplateFunctions): if group: w(':group=%s'%','.join(map(urllib.quote, group))) w(':pagesize=%s' % pagesize) - w(':startwith=%s' % startwith) + w(':startwith=0') # handle the sorting - if we're already sorting by this column, # then reverse the sorting, otherwise set the sorting to be this @@ -1433,6 +1441,9 @@ class NewItemTemplate(ItemTemplate): # # $Log: not supported by cvs2svn $ +# Revision 1.107 2002/07/30 05:27:30 richard +# nicer error messages, and a bugfix +# # Revision 1.106 2002/07/30 02:41:04 richard # Removed the confusing, ugly two-column sorting stuff. Column heading clicks # now only sort on one column. Nice and simple and obvious.