add concept search filtering select fix
This commit is contained in:
parent
7567374e50
commit
1b0f0e4859
1 changed files with 11 additions and 8 deletions
|
@ -21,6 +21,8 @@ Definition of basic view classes and other browser related stuff for the
|
||||||
loops.expert package.
|
loops.expert package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from zope import interface, component
|
from zope import interface, component
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
@ -134,7 +136,7 @@ class Search(ConceptView):
|
||||||
|
|
||||||
def getTypes(self):
|
def getTypes(self):
|
||||||
""" Return a list of type tokens from the request after checking if
|
""" Return a list of type tokens from the request after checking if
|
||||||
they fulfill certain requirements, e.g. on the length of the
|
they fulfill certain requirements, e.g. on the length of the
|
||||||
name (title, text) criteria given.
|
name (title, text) criteria given.
|
||||||
"""
|
"""
|
||||||
types = self.request.form.get('searchType')
|
types = self.request.form.get('searchType')
|
||||||
|
@ -170,7 +172,7 @@ class Search(ConceptView):
|
||||||
data = []
|
data = []
|
||||||
types = self.getTypes()
|
types = self.getTypes()
|
||||||
if title or types:
|
if title or types:
|
||||||
#if title or (types and types not in
|
#if title or (types and types not in
|
||||||
# (u'loops:concept:*', 'loops:concept:account')):
|
# (u'loops:concept:*', 'loops:concept:account')):
|
||||||
if title is not None:
|
if title is not None:
|
||||||
title = title.replace('(', ' ').replace(')', ' ').replace(' -', ' ')
|
title = title.replace('(', ' ').replace(')', ' ').replace(' -', ' ')
|
||||||
|
@ -207,13 +209,14 @@ class Search(ConceptView):
|
||||||
data.sort(key=lambda x: x['sort'])
|
data.sort(key=lambda x: x['sort'])
|
||||||
if not title:
|
if not title:
|
||||||
data.insert(0, {'label': '', 'name': '', 'id': ''})
|
data.insert(0, {'label': '', 'name': '', 'id': ''})
|
||||||
json = []
|
jsonData = dict(itentifier='id')
|
||||||
|
jsonItems = []
|
||||||
for item in data[:100]:
|
for item in data[:100]:
|
||||||
json.append("{label: '%s', name: '%s', id: '%s'}" %
|
jsonItems.append(dict(label=item['label'],
|
||||||
(item['label'], item['name'], item['id']))
|
name=item['name'],
|
||||||
json = "{identifier: 'id', items: [%s]}" % ', '.join(json)
|
id=item['id']))
|
||||||
#print '***', json
|
jsonData['items'] = jsonItems
|
||||||
return json
|
return json.dumps(jsonData)
|
||||||
|
|
||||||
def executeQuery(self, **kw):
|
def executeQuery(self, **kw):
|
||||||
return ConceptQuery(self).query(**kw)
|
return ConceptQuery(self).query(**kw)
|
||||||
|
|
Loading…
Add table
Reference in a new issue