Use data type definition to allow display of data type's label as content's tag
authorThierry Florac <tflorac@ulthar.net>
Wed, 25 Sep 2019 17:22:11 +0200
changeset 466 49f831e73fc8
parent 465 e4397e6a6890
child 467 e2398d43df0e
Use data type definition to allow display of data type's label as content's tag
src/pyams_default_theme/shared/common/__init__.py
--- a/src/pyams_default_theme/shared/common/__init__.py	Wed Sep 25 15:23:50 2019 +0200
+++ b/src/pyams_default_theme/shared/common/__init__.py	Wed Sep 25 17:22:11 2019 +0200
@@ -90,6 +90,16 @@
     return translate(context.content_name)
 
 
+@adapter_config(context=(IWfTypedSharedContent, IPyAMSUserLayer), provides=IContentTag)
+def typed_shared_content_tag_adapter(context, request):
+    """Typed shared content tag adapter"""
+    data_type = context.get_data_type()
+    if (data_type is not None) and data_type.display_as_tag:
+        return II18n(data_type).query_attribute('label', request=request)
+    else:
+        return shared_content_tag_adapter(context, request)
+
+
 @adapter_config(name='pyams_tag',
                 context=(Interface, Interface, Interface),
                 provides=ITALESExtension)