[gen] Now it is possible to index and search Ref fields.

This commit is contained in:
Gaetan Delannay 2012-09-17 21:11:54 +02:00
parent bdaf1b4bbd
commit 5f530d9f9e
8 changed files with 78 additions and 17 deletions

View file

@ -1138,4 +1138,13 @@ class ToolMixin(BaseMixin):
sendMail(appyTool, email, subject, body)
os.remove(tokenFile)
return self.goto(siteUrl, self.translate('new_password_sent'))
def getSearchValues(self, name, className):
'''Gets the possible values for selecting a value for searching field
p_name belonging to class p_className.'''
klass = self.getAppyClass(className, wrapper=True)
method = getattr(klass, name).searchSelect
tool = self.appy()
objects = method.__get__(tool)(tool)
return [(o.uid, o) for o in objects]
# ------------------------------------------------------------------------------

View file

@ -518,17 +518,14 @@ class BaseMixin:
return appyType.select(self.appy())
xhtmlToText = re.compile('<.*?>', re.S)
def getReferenceLabel(self, name, refObject):
def getReferenceLabel(self, name, refObject, className=None):
'''p_name is the name of a Ref field with link=True. I need to display,
on an edit view, the p_refObject in the listbox that will allow
the user to choose which object(s) to link through the Ref.
The information to display may only be the object title or more if
field.shownInfo is used.'''
appyType = self.getAppyType(name)
res = refObject.title
if 'title' in appyType.shownInfo:
# We may place it at another place
res = ''
appyType = self.getAppyType(name, className=className)
res = ''
for fieldName in appyType.shownInfo:
refType = refObject.o.getAppyType(fieldName)
value = getattr(refObject, fieldName)