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
Carlos Ramos Carreño
erp5
Commits
d307b9cb
Commit
d307b9cb
authored
Jan 24, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Catalog: implment getDocumentValueList() in CatalogTool.
parent
6e58cc8f
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
120 additions
and
147 deletions
+120
-147
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.py
...rtal_skins/erp5_base/NotificationTool_getDocumentValue.py
+9
-60
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.py
.../portal_skins/erp5_web/WebSection_getDocumentValueList.py
+13
-2
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.xml
...portal_skins/erp5_web/WebSection_getDocumentValueList.xml
+1
-1
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.catalog_keys.xml
...l_innodb/SQLCatalog_getDocumentValueList.catalog_keys.xml
+2
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.py
...alog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.py
+24
-34
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.xml
...log/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.xml
+2
-2
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.catalog_keys.xml
..._innodb/SQLCatalog_zGetDocumentValueList.catalog_keys.xml
+2
-0
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.sql
...og/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.sql
+3
-3
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.xml
...og/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.xml
+3
-2
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list
...5_mysql_innodb_catalog/bt/template_catalog_method_id_list
+2
-0
product/ERP5/tests/testERP5Web.py
product/ERP5/tests/testERP5Web.py
+43
-43
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+16
-0
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.py
View file @
d307b9cb
"""
This script is part of ERP5 Base
The default implementation searches for
documents which are in the user language if any
with same reference.
"""
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
notification_message_list
=
portal
.
portal_catalog
.
getDocumentValueList
(
valid_portal_type_list
=
(
'Notification Message'
,)
portal_type
=
'Notification Message'
,
validation_state
=
validation_state
or
'validated'
,
# Find the applicable language
reference
=
reference
,
if
language
in
(
None
,
''
):
language
=
language
,
language
=
portal
.
Localizer
.
get_selected_language
()
all_languages
=
True
,
)
# Find the default language
if
notification_message_list
:
default_language
=
portal
.
Localizer
.
get_default_language
()
or
'en'
return
notification_message_list
[
0
].
getObject
()
if
validation_state
is
None
:
validation_state
=
(
'validated'
,)
# Search the catalog for all documents matching the reference
# this will only return documents which are accessible by the user
notification_message_list
=
portal_catalog
(
reference
=
reference
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
language
,
sort_on
=
[(
'version'
,
'descending'
)],
group_by
=
(
'reference'
,),
**
kw
)
if
len
(
notification_message_list
)
==
0
and
language
!=
default_language
:
# Search again with English as a fallback.
notification_message_list
=
portal_catalog
(
reference
=
reference
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
default_language
,
sort_on
=
[(
'version'
,
'descending'
)],
group_by
=
(
'reference'
,),
**
kw
)
if
len
(
notification_message_list
)
==
0
:
# Search again without the language
notification_message_list
=
portal_catalog
(
reference
=
reference
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
sort_on
=
[(
'version'
,
'descending'
)],
group_by
=
(
'reference'
,),
**
kw
)
if
len
(
notification_message_list
)
==
0
:
# Default returns None
notification_message
=
None
else
:
# Try to get the first page on the list
notification_message
=
notification_message_list
[
0
]
notification_message
=
notification_message
.
getObject
()
# return the Notification Message
return
notification_message
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.py
View file @
d307b9cb
# This script returns a list of document values
# First find the Web Section or Web Site we belong to
return
context
.
WebSection_getDocumentValueListBase
(
**
kw
)
search_context
=
context
.
getWebSectionValue
()
if
all_versions
is
None
:
all_versions
=
search_context
.
getLayoutProperty
(
'layout_all_versions'
,
default
=
False
)
if
all_languages
is
None
:
all_languages
=
search_context
.
getLayoutProperty
(
'layout_all_languages'
,
default
=
False
)
return
context
.
getPortalObject
().
portal_catalog
.
getDocumentValueList
(
search_context
=
search_context
,
all_versions
=
all_versions
,
all_languages
=
all_languages
,
**
kw
)
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.xml
View file @
d307b9cb
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
<value>
<string>
all_versions=None, all_languages=None,
**kw
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.catalog_keys.xml
0 → 100644
View file @
d307b9cb
<catalog_method>
</catalog_method>
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueListBase
.py
→
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList
.py
View file @
d307b9cb
"""
"""
This script is part of ERP5 Web
ERP5 Web is a business template of ERP5 which provides a way
to create web sites which can display selected
ERP5 contents through multiple custom web layouts.
This script returns a list of document values (ie. objects or brains)
This script returns a list of document values (ie. objects or brains)
which are considered as part of this section. It can be
which are considered as part of this section. It can be
a list of web pages (usual case), a list of products
a list of web pages (usual case), a list of products
...
@@ -40,7 +34,7 @@
...
@@ -40,7 +34,7 @@
SUGGESTIONS:
SUGGESTIONS:
- Prevent showing duplicate references
- Prevent showing duplicate references
- Add documents associated to this section through 'aggregate'.
- Add documents associated to this section through 'aggregate'.
- Display only the latest version and the appropriate language.
- Display only the latest version and the appropriate language.
...
@@ -49,44 +43,43 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
...
@@ -49,44 +43,43 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
from
zExceptions
import
Unauthorized
from
zExceptions
import
Unauthorized
try
:
try
:
portal
=
container
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
kw
=
portal
.
portal_catalog
.
getSQLCatalog
().
getCannonicalArgumentDict
(
kw
)
kw
=
context
.
getCannonicalArgumentDict
(
kw
)
if
search_context
is
None
:
# First find the Web Section or Web Site we belong to
search_context
=
portal
current_section
=
context
.
getWebSectionValue
()
if
all_versions
is
None
:
all_versions
=
context
.
getLayoutProperty
(
'layout_all_versions'
,
default
=
False
)
if
all_languages
is
None
:
all_languages
=
context
.
getLayoutProperty
(
'layout_all_languages'
,
default
=
False
)
# Build the list of parameters
# Build the list of parameters
if
not
language
:
if
not
language
:
language
=
portal
.
Localizer
.
get_selected_language
()
language
=
portal
.
Localizer
.
get_selected_language
()
if
validation_state
is
None
:
if
'portal_type'
not
in
kw
:
kw
[
'portal_type'
]
=
portal
.
getPortalDocumentTypeList
()
if
'validation_state'
not
in
kw
:
# XXX hardcoded validation state list.
# XXX hardcoded validation state list.
# Use predicate or layout property instead
# Use predicate or layout property instead
validation_state
=
(
'released'
,
'released_alive'
,
'published'
,
kw
[
'validation_state'
]
=
(
'released'
,
'released_alive'
,
'published'
,
'published_alive'
,
'shared'
,
'shared_alive'
,
'published_alive'
,
'shared'
,
'shared_alive'
,
'public'
,
'validated'
)
'public'
,
'validated'
)
kw
[
'validation_state'
]
=
validation_state
if
'order_by_list'
not
in
kw
:
if
'order_by_list'
not
in
kw
:
# XXX Do not sort by default, as it increases query time
# XXX Do not sort by default, as it increases query time
kw
[
'order_by_list'
]
=
[(
'int_index'
,
'DESC'
),
(
'reference'
,
'DESC'
)]
kw
[
'order_by_list'
]
=
[(
'int_index'
,
'DESC'
),
(
'reference'
,
'DESC'
)]
if
effective_date
is
None
:
if
'effective_date'
not
in
kw
:
if
now
is
None
:
if
now
is
None
:
now
=
DateTime
()
now
=
DateTime
()
effective_date
=
ComplexQuery
(
kw
[
'effective_date'
]
=
ComplexQuery
(
SimpleQuery
(
effective_date
=
None
),
SimpleQuery
(
effective_date
=
None
),
SimpleQuery
(
effective_date
=
now
,
comparison_operator
=
'<='
),
SimpleQuery
(
effective_date
=
now
,
comparison_operator
=
'<='
),
logical_operator
=
'or'
,
logical_operator
=
'or'
,
)
)
kw
[
'effective_date'
]
=
effective_date
if
not
all_versions
:
if
all_versions
:
if
not
all_languages
:
kw
[
'language'
]
=
language
return
search_context
.
searchResults
(
src__
=
src__
,
**
kw
)
else
:
group_by_list
=
set
(
kw
.
get
(
'group_by_list'
,
[]))
group_by_list
=
set
(
kw
.
get
(
'group_by_list'
,
[]))
if
all_languages
:
if
all_languages
:
kw
[
'group_by_list'
]
=
list
(
group_by_list
.
union
((
'reference'
,
'language'
)))
kw
[
'group_by_list'
]
=
list
(
group_by_list
.
union
((
'reference'
,
'language'
)))
...
@@ -99,14 +92,11 @@ try:
...
@@ -99,14 +92,11 @@ try:
kw
.
setdefault
(
'select_dict'
,
{}).
update
(
kw
.
setdefault
(
'select_dict'
,
{}).
update
(
(
x
.
replace
(
'.'
,
'_'
)
+
'__ext__'
,
x
)
(
x
.
replace
(
'.'
,
'_'
)
+
'__ext__'
,
x
)
for
x
in
extra_column_set
if
not
x
.
endswith
(
'__score__'
))
for
x
in
extra_column_set
if
not
x
.
endswith
(
'__score__'
))
return
current_section
.
WebSection_zGetDocumentValueList
(
language
=
language
,
return
context
.
SQLCatalog_zGetDocumentValueList
(
search_context
=
search_context
,
all_languages
=
all_languages
,
language
=
language
,
src__
=
src__
,
all_languages
=
all_languages
,
kw
=
kw
)
src__
=
src__
,
else
:
kw
=
kw
)
if
not
all_languages
:
kw
[
'language'
]
=
language
return
current_section
.
searchResults
(
src__
=
src__
,
**
kw
)
except
Unauthorized
:
except
Unauthorized
:
return
[]
return
[]
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueListBase
.xml
→
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList
.xml
View file @
d307b9cb
...
@@ -50,11 +50,11 @@
...
@@ -50,11 +50,11 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
language=None, validation_state=None, all_languages=None, all_versions=None, effective_date
=None, now=None, src__=0, **kw
</string>
</value>
<value>
<string>
search_context=None, language=None, all_languages=None, all_versions
=None, now=None, src__=0, **kw
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSection_getDocumentValueListBase
</string>
</value>
<value>
<string>
SQLCatalog_getDocumentValueList
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.catalog_keys.xml
0 → 100644
View file @
d307b9cb
<catalog_method>
</catalog_method>
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection
_zGetDocumentValueList.sql
→
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog
_zGetDocumentValueList.sql
View file @
d307b9cb
<
dtml
-
let
query
=
"
buildSQLQuery
(query=portal_catalog.getSecurityQuery(**kw), **kw)"
<
dtml
-
let
query
=
"
getattr(search_context, 'buildSQLQuery', portal_catalog.buildSQLQuery)
(query=portal_catalog.getSecurityQuery(**kw), **kw)"
selection_domain
=
"kw.get('selection_domain', None)"
selection_domain
=
"kw.get('selection_domain', None)"
selection_report
=
"kw.get('selection_report', None)"
selection_report
=
"kw.get('selection_report', None)"
optimizer_switch_key_list
=
"
portal_catalog.getSQLCatalog().
getOptimizerSwitchKeyList()"
>
optimizer_switch_key_list
=
"getOptimizerSwitchKeyList()"
>
<
dtml
-
comment
>
<
dtml
-
comment
>
Currently
,
there
is
no
other
choice
to
implement
this
method
as
an
SQL
catalog
until
SQLCatalog
Currently
,
there
is
no
other
choice
to
implement
this
method
as
an
SQL
catalog
until
SQLCatalog
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
CONCAT
(
CASE
my_versioning
.
language
CONCAT
(
CASE
my_versioning
.
language
WHEN
<
dtml
-
sqlvar
language
type
=
"string"
>
THEN
'4'
WHEN
<
dtml
-
sqlvar
language
type
=
"string"
>
THEN
'4'
WHEN
''
THEN
'3'
WHEN
''
THEN
'3'
WHEN
'en'
THEN
'2'
WHEN
<
dtml
-
sqlvar
expr
=
"Localizer.get_default_language() or 'en'"
type
=
"string"
>
THEN
'2'
ELSE
'1'
END
,
ELSE
'1'
END
,
my_versioning
.
version
)
AS
priority
my_versioning
.
version
)
AS
priority
<
dtml
-
if
"query['select_expression']"
>
,
<
dtml
-
var
"query['select_expression']"
></
dtml
-
if
>
<
dtml
-
if
"query['select_expression']"
>
,
<
dtml
-
var
"query['select_expression']"
></
dtml
-
if
>
...
...
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection
_zGetDocumentValueList.xml
→
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog
_zGetDocumentValueList.xml
View file @
d307b9cb
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
</item>
</item>
<item>
<item>
<key>
<string>
arguments_src
</string>
</key>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
language\r\n
<value>
<string>
search_context\r\n
language\r\n
all_languages\r\n
all_languages\r\n
kw
</string>
</value>
kw
</string>
</value>
</item>
</item>
...
@@ -50,7 +51,7 @@ kw</string> </value>
...
@@ -50,7 +51,7 @@ kw</string> </value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSection
_zGetDocumentValueList
</string>
</value>
<value>
<string>
SQLCatalog
_zGetDocumentValueList
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
max_cache_
</string>
</key>
<key>
<string>
max_cache_
</string>
</key>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list
View file @
d307b9cb
erp5_mysql_innodb/SQLCatalog_catalogTransformation
erp5_mysql_innodb/SQLCatalog_catalogTransformation
erp5_mysql_innodb/SQLCatalog_catalogTransformationList
erp5_mysql_innodb/SQLCatalog_catalogTransformationList
erp5_mysql_innodb/SQLCatalog_getDocumentValueList
erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList
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
...
...
product/ERP5/tests/testERP5Web.py
View file @
d307b9cb
This diff is collapsed.
Click to expand it.
product/ERP5Catalog/CatalogTool.py
View file @
d307b9cb
...
@@ -1243,5 +1243,21 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
...
@@ -1243,5 +1243,21 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
db
.
query
(
r
)
db
.
query
(
r
)
return
src
return
src
# XXX which permission ?
# XXX API parameters should be explicitly defined in interface
# instead of **kw
def
getDocumentValueList
(
self
,
**
kw
):
"""
Return the list of documents which belong to the
current section. The API is designed to
support additional parameters so that it is possible
to group documents by reference, version, language, etc.
or to implement filtering of documents.
This method must be implemented through a
catalog method script :
SQLCatalog_getDocumentValueList
"""
return
self
.
getSQLCatalog
().
SQLCatalog_getDocumentValueList
(
**
kw
)
InitializeClass
(
CatalogTool
)
InitializeClass
(
CatalogTool
)
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