Commit 614d972d authored by Jérome Perrin's avatar Jérome Perrin

ERP5Type: return translated accessors in getInstancePropertySet

parent 6aba5799
...@@ -233,6 +233,12 @@ class TestContentTranslation(ERP5TypeTestCase): ...@@ -233,6 +233,12 @@ class TestContentTranslation(ERP5TypeTestCase):
self.assertEqual(address.getTranslatedStreetAddress(language='ja-kana'), '東京都 台東区') self.assertEqual(address.getTranslatedStreetAddress(language='ja-kana'), '東京都 台東区')
def test_getInstancePropertySet(self):
"""Translatable properies are returned by getInstancePropertySet
"""
self.assertTrue('en_translated_first_name' in
self.portal.portal_types.Person.getInstancePropertySet())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestContentTranslation)) suite.addTest(unittest.makeSuite(TestContentTranslation))
......
...@@ -43,6 +43,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable ...@@ -43,6 +43,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT = 'ERP5Type_asSecurityGroupId' ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT = 'ERP5Type_asSecurityGroupId'
from TranslationProviderBase import TranslationProviderBase from TranslationProviderBase import TranslationProviderBase
from Products.ERP5Type.Accessor.Translation import TRANSLATION_DOMAIN_CONTENT_TRANSLATION
from sys import exc_info from sys import exc_info
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
...@@ -518,7 +519,8 @@ class ERP5TypeInformation(XMLObject, ...@@ -518,7 +519,8 @@ class ERP5TypeInformation(XMLObject,
""" """
Return all the properties of the Portal Type Return all the properties of the Portal Type
""" """
cls = self.getPortalObject().portal_types.getPortalTypeClass(self.getId()) portal = self.getPortalObject()
cls = portal.portal_types.getPortalTypeClass(self.getId())
return_set = set() return_set = set()
for property_dict in cls.getAccessorHolderPropertyList(content=True): for property_dict in cls.getAccessorHolderPropertyList(content=True):
if property_dict['type'] == 'content': if property_dict['type'] == 'content':
...@@ -530,6 +532,17 @@ class ERP5TypeInformation(XMLObject, ...@@ -530,6 +532,17 @@ class ERP5TypeInformation(XMLObject,
if property_dict['storage_id']: if property_dict['storage_id']:
return_set.add(property_dict['storage_id']) return_set.add(property_dict['storage_id'])
if property_dict['translatable']:
domain_dict = self.getPropertyTranslationDomainDict()
domain = domain_dict.get(property_dict['id'])
if domain is None:
continue
if domain.getDomainName() == TRANSLATION_DOMAIN_CONTENT_TRANSLATION:
for language in portal.Localizer.get_languages():
return_set.add('%s_translated_%s' %
(language.replace('-', '_'),
property_dict['id']))
return return_set return return_set
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment