Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
e322e0ac
Commit
e322e0ac
authored
Jun 19, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define a scriptable key for translated_title
parent
dbdb101e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
3 deletions
+118
-3
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery.catalog_keys.xml
...nodb/SQLCatalog_makeTranslatedTitleQuery.catalog_keys.xml
+2
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery.xml
...erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery.xml
+77
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
.../CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
+1
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list
...5_mysql_innodb_catalog/bt/template_catalog_method_id_list
+1
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_scriptable_key_list
...ql_innodb_catalog/bt/template_catalog_scriptable_key_list
+2
-1
product/ERP5/tests/testContentTranslation.py
product/ERP5/tests/testContentTranslation.py
+35
-2
No files found.
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery.catalog_keys.xml
0 → 100644
View file @
e322e0ac
<catalog_method>
</catalog_method>
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery.xml
0 → 100644
View file @
e322e0ac
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, AndQuery\n
portal = context.getPortalObject()\n
\n
# This scriptable key supports content_translation if the table is present\n
catalog = portal.portal_catalog.getSQLCatalog()\n
if \'content_translation\' in catalog.getProperty(\'sql_search_tables\'):\n
return AndQuery(SimpleQuery(**{\'content_translation.translated_text\': value, \'comparison_operator\': \'match\'}),\n
Query(**{\'content_translation.property_name\': \'title\'}))\n
\n
# Otherwise it simply use title\n
return SimpleQuery(title=value)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
value
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SQLCatalog_makeTranslatedTitleQuery
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
View file @
e322e0ac
...
@@ -3,4 +3,5 @@
...
@@ -3,4 +3,5 @@
<key>
full_text | SQLCatalog_makeFullTextQuery
</key>
<key>
full_text | SQLCatalog_makeFullTextQuery
</key>
<key>
quick_search_text | SQLCatalog_makeQuickSearchQuery
</key>
<key>
quick_search_text | SQLCatalog_makeQuickSearchQuery
</key>
<key>
search_text | SQLCatalog_makeSearchTextQuery
</key>
<key>
search_text | SQLCatalog_makeSearchTextQuery
</key>
<key>
translated_title | SQLCatalog_makeTranslatedTitleQuery
</key>
</key_list>
</key_list>
\ No newline at end of file
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list
View file @
e322e0ac
...
@@ -3,6 +3,7 @@ erp5_mysql_innodb/SQLCatalog_catalogTransformationList
...
@@ -3,6 +3,7 @@ erp5_mysql_innodb/SQLCatalog_catalogTransformationList
erp5_mysql_innodb/SQLCatalog_makeFullTextQuery
erp5_mysql_innodb/SQLCatalog_makeFullTextQuery
erp5_mysql_innodb/SQLCatalog_makeQuickSearchQuery
erp5_mysql_innodb/SQLCatalog_makeQuickSearchQuery
erp5_mysql_innodb/SQLCatalog_makeSearchTextQuery
erp5_mysql_innodb/SQLCatalog_makeSearchTextQuery
erp5_mysql_innodb/SQLCatalog_makeTranslatedTitleQuery
erp5_mysql_innodb/z0_drop_alarm
erp5_mysql_innodb/z0_drop_alarm
erp5_mysql_innodb/z0_drop_catalog
erp5_mysql_innodb/z0_drop_catalog
erp5_mysql_innodb/z0_drop_category
erp5_mysql_innodb/z0_drop_category
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_scriptable_key_list
View file @
e322e0ac
...
@@ -2,3 +2,4 @@ quick_search_text | SQLCatalog_makeQuickSearchQuery
...
@@ -2,3 +2,4 @@ quick_search_text | SQLCatalog_makeQuickSearchQuery
advanced_search_text | SQLCatalog_makeQuickSearchQuery
advanced_search_text | SQLCatalog_makeQuickSearchQuery
full_text | SQLCatalog_makeFullTextQuery
full_text | SQLCatalog_makeFullTextQuery
search_text | SQLCatalog_makeSearchTextQuery
search_text | SQLCatalog_makeSearchTextQuery
translated_title | SQLCatalog_makeTranslatedTitleQuery
\ No newline at end of file
product/ERP5/tests/testContentTranslation.py
View file @
e322e0ac
...
@@ -111,7 +111,8 @@ class TestContentTranslation(ERP5TypeTestCase):
...
@@ -111,7 +111,8 @@ class TestContentTranslation(ERP5TypeTestCase):
result4
=
portal
.
portal_catalog
(
content_translation_title
=
'村岡'
)
result4
=
portal
.
portal_catalog
(
content_translation_title
=
'村岡'
)
self
.
assertEquals
(
len
(
result4
),
0
)
self
.
assertEquals
(
len
(
result4
),
0
)
# columns test
# Low level columns test. This behaviour is not guaranteed. I'm not sure
# content_translation must be a search table - jerome
result5
=
portal
.
portal_catalog
(
property_name
=
'title'
)
result5
=
portal
.
portal_catalog
(
property_name
=
'title'
)
self
.
assertEquals
(
len
(
result5
),
2
)
self
.
assertEquals
(
len
(
result5
),
2
)
result6
=
portal
.
portal_catalog
(
content_language
=
'nob-read'
)
result6
=
portal
.
portal_catalog
(
content_language
=
'nob-read'
)
...
@@ -119,6 +120,38 @@ class TestContentTranslation(ERP5TypeTestCase):
...
@@ -119,6 +120,38 @@ class TestContentTranslation(ERP5TypeTestCase):
result7
=
portal
.
portal_catalog
(
translated_text
=
'XXX YYY'
)
result7
=
portal
.
portal_catalog
(
translated_text
=
'XXX YYY'
)
self
.
assertEquals
(
len
(
result7
),
1
)
self
.
assertEquals
(
len
(
result7
),
1
)
def
testCatalogSearchTranslatedTitleScriptableKey
(
self
):
# Test 'translated_title' scriptable key.
portal
=
self
.
portal
portal
.
Localizer
.
_add_user_defined_language
(
'Nobody Readable'
,
'nob-read'
)
portal
.
Localizer
.
add_language
(
'nob-read'
)
self
.
tic
()
person
=
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
first_name
=
'Yusuke'
,
last_name
=
'Muraoka'
)
person
.
setNobReadTranslatedFirstName
(
'友介'
)
person
.
setNobReadTranslatedLastName
(
'村岡'
)
self
.
tic
()
# We can search either by the translated title
self
.
assertEquals
(
person
,
portal
.
portal_catalog
.
getResultValue
(
translated_title
=
'友介'
))
# Or the original title
self
.
assertEquals
(
person
,
portal
.
portal_catalog
.
getResultValue
(
translated_title
=
'Yusuke'
))
# documents for which translation is not set can also be found with
# translated_title key
not_translated_person
=
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
first_name
=
'Jérome'
,
last_name
=
'Perrin'
)
self
.
tic
()
self
.
assertEquals
(
not_translated_person
,
portal
.
portal_catalog
.
getResultValue
(
translated_title
=
'Jérome'
))
def
testContentTranslation
(
self
):
def
testContentTranslation
(
self
):
"""
"""
Make sure that translatable properties can have content translation into
Make sure that translatable properties can have content translation into
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment