# HG changeset patch # User Thierry Florac # Date 1522845789 -7200 # Node ID 27a1c8d531b9718275393691c1c1b673a6af2e76 # Parent c65e71af9288ecd9acc73e0cd93e6c4c78cbc9aa Use vocabulary to display milestone anchor diff -r c65e71af9288 -r 27a1c8d531b9 src/pyams_content/component/paragraph/zmi/milestone.py --- a/src/pyams_content/component/paragraph/zmi/milestone.py Wed Apr 04 14:41:57 2018 +0200 +++ b/src/pyams_content/component/paragraph/zmi/milestone.py Wed Apr 04 14:43:09 2018 +0200 @@ -59,6 +59,7 @@ from z3c.form import field, button from z3c.table.column import GetAttrColumn from zope.interface import implementer, Interface +from zope.schema.vocabulary import getVocabularyRegistry from pyams_content import _ @@ -318,16 +319,23 @@ _header = _("Anchor") weight = 30 + defaultValue = ' '.join(('-',) * 8) + def getValue(self, obj): if not obj.anchor: - return '--' + return self.defaultValue target = get_parent(self.context, IParagraphContainerTarget) if target is None: - return '--' - paragraph= IParagraphContainer(target).get(obj.anchor) - if paragraph is None: - return '--' - return II18n(paragraph).query_attribute('title', request=self.request) or '--' + return self.defaultValue + try: + vocabulary = getVocabularyRegistry().get(obj, 'PyAMS content paragraphs') + except LookupError: + paragraph = IParagraphContainer(target).get(obj.anchor) + if paragraph is None: + return self.defaultValue + return II18n(paragraph).query_attribute('title', request=self.request) or self.defaultValue + else: + return vocabulary.getTermByToken(obj.anchor).title @adapter_config(name='trash', context=(IMilestoneContainerTarget, IPyAMSLayer, MilestonesTable), provides=IColumn)