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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Noah Brackenbury
erp5
Commits
fb61a34b
Commit
fb61a34b
authored
Sep 01, 2017
by
Noah Brackenbury
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://lab.nexedi.com/nexedi/erp5
into business_bot
parents
3ef80952
a14279e5
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
69 additions
and
110 deletions
+69
-110
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.py
...rtal_skins/erp5_base/NotificationTool_getDocumentValue.py
+2
-1
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.xml
...tal_skins/erp5_base/NotificationTool_getDocumentValue.xml
+1
-1
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDefaultDocumentValue.py
...rtal_skins/erp5_web/WebSection_getDefaultDocumentValue.py
+1
-6
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValue.py
...Item/portal_skins/erp5_web/WebSection_getDocumentValue.py
+11
-88
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValue.xml
...tem/portal_skins/erp5_web/WebSection_getDocumentValue.xml
+1
-1
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.py
...alog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.py
+9
-5
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.xml
...log/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.xml
+1
-1
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.sql
...og/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.sql
+1
-2
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.xml
...og/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.xml
+1
-0
product/ERP5/tests/testERP5Web.py
product/ERP5/tests/testERP5Web.py
+7
-0
product/ERP5/tests/testNotificationMessageModule.py
product/ERP5/tests/testNotificationMessageModule.py
+6
-0
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+28
-5
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.py
View file @
fb61a34b
...
...
@@ -4,7 +4,8 @@ notification_message_list = portal.portal_catalog.getDocumentValueList(
validation_state
=
validation_state
or
'validated'
,
reference
=
reference
,
language
=
language
,
all_languages
=
True
,
strict_language
=
strict_language
,
**
kw
)
if
notification_message_list
:
return
notification_message_list
[
0
].
getObject
()
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationTool_getDocumentValue.xml
View file @
fb61a34b
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
reference, language=None, validation_state=None, **kw
</string>
</value>
<value>
<string>
reference, language=None,
strict_language=False,
validation_state=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDefaultDocumentValue.py
View file @
fb61a34b
...
...
@@ -30,9 +30,4 @@
reference_list
=
context
.
getAggregateReferenceList
()
if
not
reference_list
:
return
None
# Quick return
# We should only display those documents which are shared
# to some extend. This list takes into account some common
# state IDs used in ERP5.
return
context
.
getDocumentValue
(
name
=
reference_list
,
validation_state
=
(
'released'
,
'released_alive'
,
'published'
,
'published_alive'
,
'shared'
,
'shared_alive'
,
'public'
,
'validated'
))
return
context
.
getDocumentValue
(
name
=
reference_list
)
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValue.py
View file @
fb61a34b
"""
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.
The default implementation searches for
documents which are in the user language if any
and which reference is equal to the name parameter.
Other implementations are possible: ex. display the last
version in the closest language rather than
the latest version in the user language.
NOTE:
- the portal parameter was introduced to
fix acquisition issues within the _aq_dynamic
lookup from WebSection class.
"""
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
ComplexQuery
if
portal
is
None
:
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
# The list of portal types here should be large enough to include
# all portal_types defined in the various sections so that
# href tags which point to a document by reference can still work.
valid_portal_type_list
=
portal
.
getPortalDocumentTypeList
()
# Find the applicable language
if
language
is
None
:
language
=
portal
.
Localizer
.
get_selected_language
()
if
validation_state
is
None
:
validation_state
=
(
'released'
,
'released_alive'
,
'published'
,
'published_alive'
,
'shared'
,
'shared_alive'
,
'public'
,
'validated'
)
if
effective_date
is
None
:
if
now
is
None
:
now
=
DateTime
()
effective_date
=
ComplexQuery
(
SimpleQuery
(
effective_date
=
None
),
SimpleQuery
(
effective_date
=
now
,
comparison_operator
=
'<='
),
logical_operator
=
'or'
,
)
# Note: In sorts, NULL is considered lesser than non-NULL. So in descending
# sort, NULLs will be listed after non-NULLs, which is perfect for
# effective_date, which defines the date at which content becomes effective.
# None (NULL) effective date hence means "effective since infinite in te past".
base_sort
=
((
'effective_date'
,
'descending'
),
)
# Search the catalog for all documents matching the reference
# this will only return documents which are accessible by the user
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
(
language
,
''
),
sort_on
=
((
'language'
,
'descending'
),
)
+
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
web_page_list
)
==
0
and
language
!=
'en'
:
# Search again with English as a fallback.
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
'en'
,
sort_on
=
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
web_page_list
)
==
0
:
# Search again without the language
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
sort_on
=
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
web_page_list
)
==
0
:
# Default returns None
web_page
=
None
else
:
# Try to get the first page on the list
web_page
=
web_page_list
[
0
]
web_page
=
web_page
.
getObject
()
# return the web page
return
web_page
if
portal
is
None
:
portal
=
context
.
getPortalObject
()
document_list
=
portal
.
portal_catalog
.
getDocumentValueList
(
reference
=
name
,
language
=
language
,
strict_language
=
strict_language
,
now
=
now
,
**
kw
)
if
document_list
:
return
document_list
[
0
].
getObject
()
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValue.xml
View file @
fb61a34b
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
name, portal=None, language=None,
validation_state=None, effective_date=Non
e, now=None, **kw
</string>
</value>
<value>
<string>
name, portal=None, language=None,
strict_language=Fals
e, now=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.py
View file @
fb61a34b
...
...
@@ -52,10 +52,10 @@ try:
if
not
language
:
language
=
portal
.
Localizer
.
get_selected_language
()
if
'portal_type'
not
in
kw
:
if
not
kw
.
get
(
'portal_type'
)
:
kw
[
'portal_type'
]
=
portal
.
getPortalDocumentTypeList
()
if
'validation_state'
not
in
kw
:
if
not
kw
.
get
(
'validation_state'
)
:
# XXX hardcoded validation state list.
# Use predicate or layout property instead
kw
[
'validation_state'
]
=
(
'released'
,
'released_alive'
,
'published'
,
...
...
@@ -75,10 +75,13 @@ try:
logical_operator
=
'or'
,
)
if
all_languages
:
strict_language
=
False
if
all_versions
:
if
not
all_languages
:
kw
[
'language'
]
=
language
return
search_context
.
searchResults
(
src__
=
src__
,
**
kw
)
if
all_languages
or
not
strict_language
:
return
search_context
.
searchResults
(
src__
=
src__
,
**
kw
)
else
:
return
search_context
.
searchResults
(
src__
=
src__
,
language
=
language
,
**
kw
)
else
:
group_by_list
=
set
(
kw
.
get
(
'group_by_list'
,
[]))
if
all_languages
:
...
...
@@ -94,6 +97,7 @@ try:
for
x
in
extra_column_set
if
not
x
.
endswith
(
'__score__'
))
return
context
.
SQLCatalog_zGetDocumentValueList
(
search_context
=
search_context
,
language
=
language
,
strict_language
=
strict_language
,
all_languages
=
all_languages
,
src__
=
src__
,
kw
=
kw
)
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_getDocumentValueList.xml
View file @
fb61a34b
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
search_context=None, language=None, all_languages=None, all_versions=None, now=None, src__=0, **kw
</string>
</value>
<value>
<string>
search_context=None, language=None,
strict_language=None,
all_languages=None, all_versions=None, now=None, src__=0, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.sql
View file @
fb61a34b
...
...
@@ -57,8 +57,7 @@
<
dtml
-
if
selection_report
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_report)"
>
</
dtml
-
if
>
<
dtml
-
if
all_languages
>
<
dtml
-
else
>
<
dtml
-
if
strict_language
>
AND
my_versioning
.
language
IN
(
<
dtml
-
sqlvar
language
type
=
"string"
>
,
''
)
</
dtml
-
if
>
...
...
product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_zGetDocumentValueList.xml
View file @
fb61a34b
...
...
@@ -24,6 +24,7 @@
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
search_context\r\n
language\r\n
strict_language\r\n
all_languages\r\n
kw
</string>
</value>
</item>
...
...
product/ERP5/tests/testERP5Web.py
View file @
fb61a34b
...
...
@@ -645,6 +645,13 @@ Hé Hé Hé!""", page.asText().strip())
self
.
assertEqual
(
5
,
len
([
w
.
getLanguage
()
for
w
in
en_document_value_list
\
if
w
.
getLanguage
()
==
'ja'
]))
# Tests for strict_language=False
fallback_document_value_list
=
websection
.
getDocumentValueList
(
strict_language
=
False
,
language
=
'ja'
)
self
.
assertEqual
(
[(
'en'
,
'D'
),
(
'ja'
,
'A'
),
(
'ja'
,
'B'
),
(
'ja'
,
'C'
),
(
'ja'
,
'E'
),
(
'pt'
,
'F'
)],
sorted
([(
x
.
getLanguage
(),
x
.
getReference
())
for
x
in
fallback_document_value_list
])
)
# Tests for sort_on parameter
self
.
assertEqual
([
'A'
,
'B'
,
'C'
,
'D'
],
[
w
.
getReference
()
for
w
in
\
...
...
product/ERP5/tests/testNotificationMessageModule.py
View file @
fb61a34b
...
...
@@ -83,6 +83,8 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
tic
()
result
=
tool
.
getDocumentValue
(
reference
=
'A'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_en
.
getRelativeUrl
())
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_en
.
getRelativeUrl
())
#Same Document A in French
n_m_fr
=
module
.
newContent
(
portal_type
=
'Notification Message'
,
reference
=
'A'
,
...
...
@@ -90,6 +92,8 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
version
=
'01'
)
n_m_fr
.
validate
()
self
.
tic
()
result
=
tool
.
getDocumentValue
(
reference
=
'A'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_en
.
getRelativeUrl
())
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_fr
.
getRelativeUrl
())
#Duplicate Document A French with upgraded version
...
...
@@ -99,6 +103,8 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
version
=
'02'
)
n_m_fr_02
.
validate
()
self
.
tic
()
result
=
tool
.
getDocumentValue
(
reference
=
'A'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_en
.
getRelativeUrl
())
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_fr_02
.
getRelativeUrl
())
...
...
product/ERP5Catalog/CatalogTool.py
View file @
fb61a34b
...
...
@@ -1242,10 +1242,11 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
db
.
query
(
r
)
return
src
# XXX which permission ?
# XXX API parameters should be explicitly defined in interface
# instead of **kw
def
getDocumentValueList
(
self
,
**
kw
):
security
.
declarePublic
(
'getDocumentValueList'
)
def
getDocumentValueList
(
self
,
sql_catalog_id
=
None
,
search_context
=
None
,
language
=
None
,
strict_language
=
True
,
all_languages
=
None
,
all_versions
=
None
,
now
=
None
,
**
kw
):
"""
Return the list of documents which belong to the
current section. The API is designed to
...
...
@@ -1256,7 +1257,29 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
This method must be implemented through a
catalog method script :
SQLCatalog_getDocumentValueList
Here is the list of arguments :
* search_context
* language
* strict_language
* all_languages
* all_versions
* now
If you specify search_context, its predicate will be
respected,
i.e. web_section.WebSection_getDocumentValueList is
equivalent to
portal_catalog.getDocumentValueList(search_context=web_section)
"""
return
self
.
getSQLCatalog
().
SQLCatalog_getDocumentValueList
(
**
kw
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
return
catalog
.
SQLCatalog_getDocumentValueList
(
search_context
=
search_context
,
language
=
language
,
strict_language
=
strict_language
,
all_languages
=
all_languages
,
all_versions
=
all_versions
,
now
=
now
,
**
kw
)
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