diff --git a/themis/fields/vocabs.py b/themis/fields/vocabs.py index 62b42da..128304c 100644 --- a/themis/fields/vocabs.py +++ b/themis/fields/vocabs.py @@ -14,6 +14,7 @@ from Products.CMFCore.utils import getToolByName from plone.registry.interfaces import IRegistry from plone.formwidget.contenttree import ObjPathSourceBinder +from plone.formwidget.contenttree.source import ObjPathSource try: from tabellio.config.interfaces import ITabellioSettings @@ -334,7 +335,19 @@ class LegislativeSessionsSource(object): # Legislative sessions # hack to let schema editor handle the field yield u'DO NOT TOUCH' +class RelatedDocObjPathSource(ObjPathSource): + def getTermByBrain(self, brain, real_value=True): + if real_value: + value = brain._unrestrictedGetObject() + else: + value = brain.getPath()[len(self.portal_path):] + return SimpleTerm(value, token=brain.getPath(), title=u'%s [%s]' % ( + unicode(brain.Title, 'utf-8'), + brain.getObject().Type())) + class RelatedDocObjPathSourceBinder(ObjPathSourceBinder): + path_source = RelatedDocObjPathSource + def __iter__(self): # hack to let schema editor handle the field yield u'DO NOT TOUCH'