From 46a4ede74036088ffc08ffb4637de1acc7a77819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 20 Jan 2012 10:55:26 +0100 Subject: [PATCH] append object type next to object title in related docs --- themis/fields/vocabs.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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'