Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
95d2eed2
Commit
95d2eed2
authored
Jan 24, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_base: implement getDocumentValueList() in FolderMixin so that we can use DMS API everywhere.
parent
cb011599
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
114 deletions
+118
-114
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getDocumentValueList.py
...eItem/portal_skins/erp5_base/Base_getDocumentValueList.py
+27
-30
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_getDocumentValueList.xml
...Item/portal_skins/erp5_base/Base_getDocumentValueList.xml
+2
-2
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_zGetDocumentValueList.sql
...tem/portal_skins/erp5_base/Base_zGetDocumentValueList.sql
+2
-2
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_zGetDocumentValueList.xml
...tem/portal_skins/erp5_base/Base_zGetDocumentValueList.xml
+1
-1
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.py
.../portal_skins/erp5_web/WebSection_getDocumentValueList.py
+1
-2
product/ERP5/Document/WebSection.py
product/ERP5/Document/WebSection.py
+0
-32
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getSearchResultList.py
...em/portal_skins/erp5_core/ERP5Site_getSearchResultList.py
+5
-2
product/ERP5/tests/testERP5Web.py
product/ERP5/tests/testERP5Web.py
+43
-43
product/ERP5Type/Core/Folder.py
product/ERP5Type/Core/Folder.py
+37
-0
No files found.
bt5/erp5_
web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueListBase
.py
→
bt5/erp5_
base/SkinTemplateItem/portal_skins/erp5_base/Base_getDocumentValueList
.py
View file @
95d2eed2
"""
"""
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
...
@@ -52,41 +46,48 @@ try:
...
@@ -52,41 +46,48 @@ try:
portal
=
container
.
getPortalObject
()
portal
=
container
.
getPortalObject
()
kw
=
portal
.
portal_catalog
.
getSQLCatalog
().
getCannonicalArgumentDict
(
kw
)
kw
=
portal
.
portal_catalog
.
getSQLCatalog
().
getCannonicalArgumentDict
(
kw
)
#
First
find the Web Section or Web Site we belong to
#
Try to
find the Web Section or Web Site we belong to
current_section
=
context
.
getWebSectionValue
()
current_section
=
context
.
getWebSectionValue
()
if
current_section
is
None
:
current_section
=
context
else
:
if
all_versions
is
None
:
if
all_versions
is
None
:
all_versions
=
context
.
getLayoutProperty
(
'layout_all_versions'
,
default
=
False
)
all_versions
=
current_section
.
getLayoutProperty
(
'layout_all_versions'
,
default
=
False
)
if
all_languages
is
None
:
if
all_languages
is
None
:
all_languages
=
context
.
getLayoutProperty
(
'layout_all_languages'
,
default
=
False
)
all_languages
=
current_section
.
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
current_section
.
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 +100,10 @@ try:
...
@@ -99,14 +100,10 @@ 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
current_section
.
Base
_zGetDocumentValueList
(
language
=
language
,
all_languages
=
all_languages
,
all_languages
=
all_languages
,
src__
=
src__
,
src__
=
src__
,
kw
=
kw
)
kw
=
kw
)
else
:
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
→
bt5/erp5_
base/SkinTemplateItem/portal_skins/erp5_base/Base_getDocumentValueList
.xml
View file @
95d2eed2
...
@@ -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>
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>
Base_getDocumentValueList
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
bt5/erp5_
web/SkinTemplateItem/portal_skins/erp5_web/WebSection
_zGetDocumentValueList.sql
→
bt5/erp5_
base/SkinTemplateItem/portal_skins/erp5_base/Base
_zGetDocumentValueList.sql
View file @
95d2eed2
<
dtml
-
let
query
=
"
buildSQLQuery
(query=portal_catalog.getSecurityQuery(**kw), **kw)"
<
dtml
-
let
query
=
"
(_.has_key('buildSQLQuery') and buildSQLQuery or 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
=
"portal_catalog.getSQLCatalog().getOptimizerSwitchKeyList()"
>
...
@@ -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
→
bt5/erp5_
base/SkinTemplateItem/portal_skins/erp5_base/Base
_zGetDocumentValueList.xml
View file @
95d2eed2
...
@@ -50,7 +50,7 @@ kw</string> </value>
...
@@ -50,7 +50,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>
Base
_zGetDocumentValueList
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
max_cache_
</string>
</key>
<key>
<string>
max_cache_
</string>
</key>
...
...
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getDocumentValueList.py
View file @
95d2eed2
# This script returns a list of document values
return
context
.
Base_getDocumentValueList
(
**
kw
)
return
context
.
WebSection_getDocumentValueListBase
(
**
kw
)
product/ERP5/Document/WebSection.py
View file @
95d2eed2
...
@@ -312,38 +312,6 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
...
@@ -312,38 +312,6 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
return
result
return
result
security
.
declareProtected
(
Permissions
.
View
,
'getDocumentValueList'
)
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
portal type dependent script:
WebSection_getDocumentValueList
"""
cache
=
getReadOnlyTransactionCache
()
if
cache
is
not
None
:
key
=
(
'getDocumentValueList'
,
self
)
+
tuple
(
kw
.
items
())
try
:
return
cache
[
key
]
except
KeyError
:
pass
result
=
self
.
_getTypeBasedMethod
(
'getDocumentValueList'
,
fallback_script_id
=
'WebSection_getDocumentValueList'
)(
**
kw
)
if
cache
is
not
None
:
cache
[
key
]
=
result
if
result
is
not
None
and
not
kw
.
get
(
'src__'
,
0
):
result
=
[
doc
.
__of__
(
self
)
for
doc
in
result
]
return
result
security
.
declareProtected
(
Permissions
.
View
,
'getPermanentURL'
)
security
.
declareProtected
(
Permissions
.
View
,
'getPermanentURL'
)
def
getPermanentURL
(
self
,
document
,
view
=
True
):
def
getPermanentURL
(
self
,
document
,
view
=
True
):
"""
"""
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getSearchResultList.py
View file @
95d2eed2
search_method
=
getattr
(
context
,
'getDocumentValueList'
,
# Use getDocumentValueList for ERP5 Web
context
.
getPortalObject
().
portal_catalog
)
if
context
.
getWebSectionValue
()
is
None
:
search_method
=
context
.
getPortalObject
().
portal_catalog
else
:
search_method
=
context
.
getDocumentValueList
return
search_method
(
**
kw
)
return
search_method
(
**
kw
)
product/ERP5/tests/testERP5Web.py
View file @
95d2eed2
...
@@ -360,7 +360,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -360,7 +360,7 @@ Hé Hé Hé!""", page.asText().strip())
websection
.
getAggregateReferenceList
())
websection
.
getAggregateReferenceList
())
# even though we create many pages we should get only one
# even though we create many pages we should get only one
# this is the most recent one since all share the same reference
# this is the most recent one since all share the same reference
self
.
assertEqual
(
1
,
len
(
websection
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
websection
.
getDocumentValueList
()))
# use already created few pages in different languages with same reference
# use already created few pages in different languages with same reference
# and check that we always get the right one based on selected
# and check that we always get the right one based on selected
...
@@ -483,7 +483,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -483,7 +483,7 @@ Hé Hé Hé!""", page.asText().strip())
base_url
=
base_list
[
0
]
base_url
=
base_list
[
0
]
self
.
assertEqual
(
base_url
,
"%s/%s/"
%
(
website
.
absolute_url
(),
web_page_en
.
getReference
()))
self
.
assertEqual
(
base_url
,
"%s/%s/"
%
(
website
.
absolute_url
(),
web_page_en
.
getReference
()))
def
test_07_
WebSection_
getDocumentValueList
(
self
):
def
test_07_getDocumentValueList
(
self
):
""" Check getting getDocumentValueList from Web Section.
""" Check getting getDocumentValueList from Web Section.
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
getPortal
()
...
@@ -530,7 +530,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -530,7 +530,7 @@ Hé Hé Hé!""", page.asText().strip())
sequence_count
=
0
sequence_count
=
0
for
sequence
in
[
sequence_one
,
sequence_two
,
sequence_three
]:
for
sequence
in
[
sequence_one
,
sequence_two
,
sequence_three
]:
sequence_count
+=
1
sequence_count
+=
1
message
=
'
\
n
test_07_
WebSection_
getDocumentValueList (Sequence %s)'
\
message
=
'
\
n
test_07_getDocumentValueList (Sequence %s)'
\
%
(
sequence_count
)
%
(
sequence_count
)
ZopeTestCase
.
_print
(
message
)
ZopeTestCase
.
_print
(
message
)
...
@@ -603,7 +603,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -603,7 +603,7 @@ Hé Hé Hé!""", page.asText().strip())
[
w
.
getLanguage
()
for
w
in
ja_document_value_list
])
[
w
.
getLanguage
()
for
w
in
ja_document_value_list
])
# Tests for all_languages parameter (language parameter is simply ignored)
# Tests for all_languages parameter (language parameter is simply ignored)
en_document_value_list
=
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
)
en_document_value_list
=
websection
.
getDocumentValueList
(
all_languages
=
1
)
self
.
assertEqual
(
13
,
len
(
en_document_value_list
))
self
.
assertEqual
(
13
,
len
(
en_document_value_list
))
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
en_document_value_list
\
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
en_document_value_list
\
if
w
.
getLanguage
()
==
'en'
]))
if
w
.
getLanguage
()
==
'en'
]))
...
@@ -612,7 +612,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -612,7 +612,7 @@ Hé Hé Hé!""", page.asText().strip())
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
en_document_value_list
\
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
en_document_value_list
\
if
w
.
getLanguage
()
==
'ja'
]))
if
w
.
getLanguage
()
==
'ja'
]))
pt_document_value_list
=
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
pt_document_value_list
=
websection
.
getDocumentValueList
(
all_languages
=
1
,
language
=
'pt'
)
language
=
'pt'
)
self
.
assertEqual
(
13
,
len
(
pt_document_value_list
))
self
.
assertEqual
(
13
,
len
(
pt_document_value_list
))
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
pt_document_value_list
\
self
.
assertEqual
(
4
,
len
([
w
.
getLanguage
()
for
w
in
pt_document_value_list
\
...
@@ -623,14 +623,14 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -623,14 +623,14 @@ Hé Hé Hé!""", page.asText().strip())
if
w
.
getLanguage
()
==
'ja'
]))
if
w
.
getLanguage
()
==
'ja'
]))
# Tests for all_languages and all_versions
# Tests for all_languages and all_versions
en_document_value_list
=
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
en_document_value_list
=
websection
.
getDocumentValueList
(
all_languages
=
1
,
all_versions
=
1
)
all_versions
=
1
)
pt_document_value_list
=
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
pt_document_value_list
=
websection
.
getDocumentValueList
(
all_languages
=
1
,
all_versions
=
1
,
all_versions
=
1
,
language
=
'pt'
)
language
=
'pt'
)
ja_document_value_list
=
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
ja_document_value_list
=
websection
.
getDocumentValueList
(
all_languages
=
1
,
all_versions
=
1
,
all_versions
=
1
,
language
=
'ja'
)
language
=
'ja'
)
...
@@ -664,22 +664,22 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -664,22 +664,22 @@ Hé Hé Hé!""", page.asText().strip())
self
.
assertEqual
([
'A'
,
'A'
,
'A'
,
'A'
,
'B'
,
'B'
,
'B'
,
'C'
,
'C'
,
'C'
,
'D'
,
'E'
,
'F'
],
self
.
assertEqual
([
'A'
,
'A'
,
'A'
,
'A'
,
'B'
,
'B'
,
'B'
,
'C'
,
'C'
,
'C'
,
'D'
,
'E'
,
'F'
],
[
w
.
getReference
()
for
w
in
\
[
w
.
getReference
()
for
w
in
\
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
websection
.
getDocumentValueList
(
all_languages
=
1
,
sort_on
=
[(
'reference'
,
'ASC'
)])])
sort_on
=
[(
'reference'
,
'ASC'
)])])
self
.
assertEqual
([
'01'
,
'02'
,
'03'
,
'04'
,
'05'
,
'06'
,
'07'
,
'08'
,
'09'
,
'11'
,
'12'
,
'13'
,
'16'
],
self
.
assertEqual
([
'01'
,
'02'
,
'03'
,
'04'
,
'05'
,
'06'
,
'07'
,
'08'
,
'09'
,
'11'
,
'12'
,
'13'
,
'16'
],
[
w
.
getTitle
()
for
w
in
\
[
w
.
getTitle
()
for
w
in
\
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
websection
.
getDocumentValueList
(
all_languages
=
1
,
sort_on
=
[(
'title'
,
'ASC'
)])])
sort_on
=
[(
'title'
,
'ASC'
)])])
self
.
assertEqual
([
'F'
,
'E'
,
'D'
,
'C'
,
'C'
,
'C'
,
'B'
,
'B'
,
'B'
,
'A'
,
'A'
,
'A'
,
'A'
],
self
.
assertEqual
([
'F'
,
'E'
,
'D'
,
'C'
,
'C'
,
'C'
,
'B'
,
'B'
,
'B'
,
'A'
,
'A'
,
'A'
,
'A'
],
[
w
.
getReference
()
for
w
in
\
[
w
.
getReference
()
for
w
in
\
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
websection
.
getDocumentValueList
(
all_languages
=
1
,
sort_on
=
[(
'reference'
,
'DESC'
)])])
sort_on
=
[(
'reference'
,
'DESC'
)])])
self
.
assertEqual
([
'16'
,
'13'
,
'12'
,
'11'
,
'09'
,
'08'
,
'07'
,
'06'
,
'05'
,
'04'
,
'03'
,
'02'
,
'01'
],
self
.
assertEqual
([
'16'
,
'13'
,
'12'
,
'11'
,
'09'
,
'08'
,
'07'
,
'06'
,
'05'
,
'04'
,
'03'
,
'02'
,
'01'
],
[
w
.
getTitle
()
for
w
in
\
[
w
.
getTitle
()
for
w
in
\
websection
.
WebSection_getDocumentValueListBase
(
all_languages
=
1
,
websection
.
getDocumentValueList
(
all_languages
=
1
,
sort_on
=
[(
'title'
,
'DESC'
)])])
sort_on
=
[(
'title'
,
'DESC'
)])])
self
.
web_page_module
.
manage_delObjects
(
list
(
self
.
web_page_module
.
objectIds
()))
self
.
web_page_module
.
manage_delObjects
(
list
(
self
.
web_page_module
.
objectIds
()))
...
@@ -1566,7 +1566,7 @@ Hé Hé Hé!""", page.asText().strip())
...
@@ -1566,7 +1566,7 @@ Hé Hé Hé!""", page.asText().strip())
document
=
section
.
WebSection_getDocumentValue
(
reference
,
now
=
date
)
document
=
section
.
WebSection_getDocumentValue
(
reference
,
now
=
date
)
self
.
assertNotEqual
(
document
,
None
)
self
.
assertNotEqual
(
document
,
None
)
self
.
assertEqual
(
document
.
getPath
(),
expected_document
.
getPath
())
self
.
assertEqual
(
document
.
getPath
(),
expected_document
.
getPath
())
document_list
=
section
.
WebSection_
getDocumentValueList
(
now
=
date
)
document_list
=
section
.
getDocumentValueList
(
now
=
date
)
self
.
assertEqual
(
len
(
document_list
),
1
)
self
.
assertEqual
(
len
(
document_list
),
1
)
self
.
assertEqual
(
document_list
[
0
].
getPath
(),
expected_document
.
getPath
())
self
.
assertEqual
(
document_list
[
0
].
getPath
(),
expected_document
.
getPath
())
# document1 is visible & listed before date2
# document1 is visible & listed before date2
...
@@ -1699,8 +1699,8 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -1699,8 +1699,8 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self
.
assertSameSet
((),
self
.
assertSameSet
((),
section
.
get_local_roles_for_userid
(
person_user_id
))
section
.
get_local_roles_for_userid
(
person_user_id
))
def
test_03_
WebSection_
getDocumentValueListSecurity
(
self
):
def
test_03_getDocumentValueListSecurity
(
self
):
""" Test
WebSection_
getDocumentValueList behaviour and security"""
""" Test getDocumentValueList behaviour and security"""
self
.
loginByUserName
(
'admin'
)
self
.
loginByUserName
(
'admin'
)
site
=
self
.
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
,
site
=
self
.
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
,
id
=
'site'
)
id
=
'site'
)
...
@@ -1751,28 +1751,28 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -1751,28 +1751,28 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
self
.
loginByUserName
(
'erp5user'
)
self
.
loginByUserName
(
'erp5user'
)
page_en_0
.
publish
()
page_en_0
.
publish
()
self
.
tic
()
self
.
tic
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
self
.
assertEqual
(
page_en_0
.
getUid
(),
self
.
assertEqual
(
page_en_0
.
getUid
(),
section
.
WebSection_
getDocumentValueList
()[
0
].
getUid
())
section
.
getDocumentValueList
()[
0
].
getUid
())
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
# By Anonymous
# By Anonymous
self
.
logout
()
self
.
logout
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
self
.
assertEqual
(
page_en_0
.
getUid
(),
self
.
assertEqual
(
page_en_0
.
getUid
(),
section
.
WebSection_
getDocumentValueList
()[
0
].
getUid
())
section
.
getDocumentValueList
()[
0
].
getUid
())
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
# Second Object
# Second Object
self
.
loginByUserName
(
'erp5user'
)
self
.
loginByUserName
(
'erp5user'
)
...
@@ -1780,18 +1780,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -1780,18 +1780,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
self
.
assertEqual
(
page_en_1
.
getUid
(),
self
.
assertEqual
(
page_en_1
.
getUid
(),
section
.
WebSection_
getDocumentValueList
()[
0
].
getUid
())
section
.
getDocumentValueList
()[
0
].
getUid
())
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
# By Anonymous
# By Anonymous
self
.
logout
()
self
.
logout
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
self
.
assertEqual
(
page_en_1
.
getUid
(),
self
.
assertEqual
(
page_en_1
.
getUid
(),
section
.
WebSection_
getDocumentValueList
()[
0
].
getUid
())
section
.
getDocumentValueList
()[
0
].
getUid
())
# Trird Object
# Trird Object
self
.
loginByUserName
(
'erp5user'
)
self
.
loginByUserName
(
'erp5user'
)
...
@@ -1799,16 +1799,16 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -1799,16 +1799,16 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
2
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
2
,
len
(
section
.
getDocumentValueList
()))
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
# By Anonymous
# By Anonymous
self
.
logout
()
self
.
logout
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
2
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
2
,
len
(
section
.
getDocumentValueList
()))
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
0
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
0
,
len
(
section
.
getDocumentValueList
()))
# First Japanese Object
# First Japanese Object
self
.
loginByUserName
(
'erp5user'
)
self
.
loginByUserName
(
'erp5user'
)
...
@@ -1816,18 +1816,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -1816,18 +1816,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
2
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
2
,
len
(
section
.
getDocumentValueList
()))
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
# By Anonymous
# By Anonymous
self
.
logout
()
self
.
logout
()
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'en'
)
self
.
assertEqual
(
2
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
2
,
len
(
section
.
getDocumentValueList
()))
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
portal
.
Localizer
.
changeLanguage
(
'jp'
)
self
.
assertEqual
(
1
,
len
(
section
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
section
.
getDocumentValueList
()))
self
.
assertEqual
(
page_jp_0
.
getUid
(),
self
.
assertEqual
(
page_jp_0
.
getUid
(),
section
.
WebSection_
getDocumentValueList
()[
0
].
getUid
())
section
.
getDocumentValueList
()[
0
].
getUid
())
def
test_04_ExpireUserAction
(
self
):
def
test_04_ExpireUserAction
(
self
):
""" Test the expire user action"""
""" Test the expire user action"""
...
@@ -2055,10 +2055,10 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
...
@@ -2055,10 +2055,10 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
web_page_no_follow_up
.
publish
()
web_page_no_follow_up
.
publish
()
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
1
,
len
(
website
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
website
.
getDocumentValueList
()))
self
.
logout
()
self
.
logout
()
self
.
assertEqual
(
1
,
len
(
website
.
WebSection_
getDocumentValueList
()))
self
.
assertEqual
(
1
,
len
(
website
.
getDocumentValueList
()))
def
test_WebSiteModuleDefaultSecurity
(
self
):
def
test_WebSiteModuleDefaultSecurity
(
self
):
"""
"""
...
...
product/ERP5Type/Core/Folder.py
View file @
95d2eed2
...
@@ -42,6 +42,7 @@ from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
...
@@ -42,6 +42,7 @@ from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from
Products.CMFCore.PortalFolder
import
ContentFilter
from
Products.CMFCore.PortalFolder
import
ContentFilter
from
Products.ERP5Type.Base
import
Base
from
Products.ERP5Type.Base
import
Base
from
Products.ERP5Type.Cache
import
getReadOnlyTransactionCache
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
from
Products.ERP5Type.CopySupport
import
CopyContainer
from
Products.ERP5Type.CopySupport
import
CopyContainer
from
Products.ERP5Type
import
PropertySheet
from
Products.ERP5Type
import
PropertySheet
...
@@ -431,6 +432,42 @@ class FolderMixIn(ExtensionClass.Base):
...
@@ -431,6 +432,42 @@ class FolderMixIn(ExtensionClass.Base):
else
:
else
:
return
None
return
None
security
.
declareProtected
(
Permissions
.
View
,
'getDocumentValueList'
)
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
portal type dependent script like :
Base_getDocumentValueList
"""
cache
=
getReadOnlyTransactionCache
()
if
cache
is
not
None
:
key
=
(
'getDocumentValueList'
,
self
)
+
tuple
(
kw
.
items
())
try
:
return
cache
[
key
]
except
KeyError
:
pass
_getTypeBasedMethod
=
getattr
(
self
,
'_getTypeBasedMethod'
,
None
)
if
_getTypeBasedMethod
is
None
:
result
=
self
.
Base_getDocumentValueList
(
**
kw
)
else
:
result
=
_getTypeBasedMethod
(
'getDocumentValueList'
,
fallback_script_id
=
'Base_getDocumentValueList'
)(
**
kw
)
if
cache
is
not
None
:
cache
[
key
]
=
result
if
result
is
not
None
and
not
kw
.
get
(
'src__'
,
0
):
result
=
[
doc
.
__of__
(
self
)
for
doc
in
result
]
return
result
def
_recurseCallMethod
(
self
,
method_id
,
method_args
=
(),
method_kw
=
{},
def
_recurseCallMethod
(
self
,
method_id
,
method_args
=
(),
method_kw
=
{},
restricted
=
False
,
id_list
=
None
,
min_id
=
None
,
**
kw
):
restricted
=
False
,
id_list
=
None
,
min_id
=
None
,
**
kw
):
"""Run a script by activity on objects found recursively from this folder
"""Run a script by activity on objects found recursively from this folder
...
...
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