add new method to get title out of vocab
This commit is contained in:
parent
410e105e26
commit
158428aadc
|
@ -178,6 +178,26 @@ class ContactsSource(object):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def fastGetTitleByToken(self, context, token):
|
||||
if not ':' in token:
|
||||
return token
|
||||
if token == 'ministry:college':
|
||||
return u'Collège'
|
||||
prefix, value = token.split(':')
|
||||
portal = getToolByName(context, 'portal_url').getPortalObject()
|
||||
if prefix == 'deputy':
|
||||
url = 'deputes'
|
||||
elif prefix in ('ministry', 'ministry-collab'):
|
||||
url = 'ministres'
|
||||
elif prefix == 'contact':
|
||||
url = 'contacts'
|
||||
else:
|
||||
raise KeyError(token)
|
||||
try:
|
||||
return getattr(getattr(portal, url), value).Title()
|
||||
except AttributeError:
|
||||
raise KeyError(token)
|
||||
|
||||
def __call__(self, context):
|
||||
catalog = getToolByName(context, 'portal_catalog')
|
||||
|
||||
|
|
Reference in New Issue