Added alternate title to logos
authorThierry Florac <tflorac@ulthar.net>
Fri, 13 Nov 2020 13:04:58 +0100
changeset 1426 ea7a363b538e
parent 1425 7d924651271c
child 1427 43bd56f3a726
Added alternate title to logos
src/pyams_content/shared/logo/__init__.py
src/pyams_content/shared/logo/interfaces.py
src/pyams_content/shared/logo/zmi/properties.py
--- a/src/pyams_content/shared/logo/__init__.py	Fri Nov 13 13:03:35 2020 +0100
+++ b/src/pyams_content/shared/logo/__init__.py	Fri Nov 13 13:04:58 2020 +0100
@@ -24,6 +24,7 @@
     register_content_type
 from pyams_content.shared.logo.interfaces import ILogo, IWfLogo, IWfLogoFactory, LOGO_CONTENT_NAME, LOGO_CONTENT_TYPE
 from pyams_file.property import FileProperty
+from pyams_i18n.interfaces import II18n
 from pyams_utils.adapter import adapter_config
 
 
@@ -41,9 +42,15 @@
     acronym = FieldProperty(IWfLogo['acronym'])
     url = FieldProperty(IWfLogo['url'])
     reference = FieldProperty(IWfLogo['reference'])
+    alt_title = FieldProperty(IWfLogo['alt_title'])
     image = FileProperty(IWfLogo['image'])
     monochrome_image = FileProperty(IWfLogo['monochrome_image'])
 
+    def get_title(self, request):
+        i18n = II18n(self)
+        return i18n.query_attribute('alt_title', request=request) or \
+            i18n.query_attribute('title', request=request)
+
 
 register_content_type(WfLogo, shared_content=False)
 
--- a/src/pyams_content/shared/logo/interfaces.py	Fri Nov 13 13:03:35 2020 +0100
+++ b/src/pyams_content/shared/logo/interfaces.py	Fri Nov 13 13:04:58 2020 +0100
@@ -52,11 +52,17 @@
               required=False)
 
     reference = InternalReferenceField(title=_("Internal reference"),
-                                       description=_("Internal link target reference. You can search a reference using "
-                                                     "'+' followed by internal number, of by entering text matching "
-                                                     "content title."),
+                                       description=_("Internal link target reference. You can "
+                                                     "search a reference using '+' followed by "
+                                                     "internal number, of by entering text "
+                                                     "matching content title."),
                                        required=False)
 
+    alt_title = I18nTextLineField(title=_("Alternate title"),
+                                  description=_("If set, this title will be displayed in "
+                                                "front-office instead of original title"),
+                                  required=False)
+
     image = ImageField(title=_("Image (colored)"),
                        description=_("Image data"),
                        required=True)
--- a/src/pyams_content/shared/logo/zmi/properties.py	Fri Nov 13 13:03:35 2020 +0100
+++ b/src/pyams_content/shared/logo/zmi/properties.py	Fri Nov 13 13:04:58 2020 +0100
@@ -61,7 +61,8 @@
     legend = _("Main logo settings")
     fieldset_class = 'bordered no-x-margin margin-y-10'
 
-    fields = field.Fields(IWfLogo).select('acronym', 'url', 'reference', 'image', 'monochrome_image')
+    fields = field.Fields(IWfLogo).select('acronym', 'url', 'reference', 'alt_title',
+                                          'image', 'monochrome_image')
     weight = 1
 
     def get_ajax_output(self, changes):