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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
ddc1fd16
Commit
ddc1fd16
authored
Mar 12, 2021
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Plain Diff
erp5_core: Make two queries in Base_getRelatedDocumentList
See merge request
!1373
parents
42c2a915
aba2d822
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
+52
-5
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+38
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedDocumentList.py
...tem/portal_skins/erp5_core/Base_getRelatedDocumentList.py
+14
-5
No files found.
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
ddc1fd16
...
...
@@ -2896,6 +2896,44 @@ return 1
self
.
assertEqual
(
'TEST-001-en.dummy'
,
document
.
getStandardFilename
(
document_format
))
def
test_Base_getRelatedDocumentList
(
self
):
"""
Checks Base_getRelatedDocumentList works correctly with both
related (follow_up) Documents and with sub-object Embedded Files
"""
uploaded_file
=
makeFileUpload
(
'TEST-001-en.dummy'
)
document_value
=
self
.
portal
.
Base_contribute
(
file
=
uploaded_file
,
synchronous_metadata_discovery
=
True
,
portal_type
=
'File'
)
person_value
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
getRelatedDocumentList
=
person_value
.
Base_getRelatedDocumentList
self
.
tic
()
# No related document
self
.
assertEqual
(
len
(
getRelatedDocumentList
()),
0
)
document_value
.
setFollowUpValue
(
person_value
)
self
.
tic
()
# Only related follow_up File
self
.
assertEqual
(
[
brain
.
getObject
()
for
brain
in
getRelatedDocumentList
()],
[
document_value
]
)
sub_document_value
=
person_value
.
newContent
(
portal_type
=
'Embedded File'
)
self
.
tic
()
# Related follow_up File and Embedded File
self
.
assertEqual
(
sorted
([
brain
.
getObject
()
for
brain
in
getRelatedDocumentList
()]),
sorted
([
sub_document_value
,
document_value
])
)
document_value
.
setFollowUpValue
(
None
)
self
.
tic
()
# Only related Embedded File
self
.
assertEqual
(
[
brain
.
getObject
()
for
brain
in
getRelatedDocumentList
()],
[
sub_document_value
]
)
class
TestDocumentWithSecurity
(
TestDocumentMixin
):
username
=
'yusei'
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedDocumentList.py
View file @
ddc1fd16
...
...
@@ -7,12 +7,20 @@ portal_catalog = portal.portal_catalog
if
portal_type
is
None
:
portal_type
=
portal
.
getPortalDocumentTypeList
()
+
portal
.
getPortalEmbeddedDocumentTypeList
()
document_query
=
ComplexQuery
(
Query
(
follow_up_uid
=
context
.
getUid
())
,
Query
(
relative_url
=
'%s/%%'
%
context
.
getRelativeUrl
().
replace
(
'_'
,
r'\
_
')
),
logical_operator='
or
'
limit
=
kw
.
pop
(
'limit'
,
None
)
follow_up_related_document_list
=
portal_catalog
(
portal_type
=
portal_type
,
follow_up_uid
=
context
.
getUid
(
),
**
kw
)
if
follow_up_related_document_list
:
document_query
=
ComplexQuery
(
Query
(
relative_url
=
'%s/%%'
%
context
.
getRelativeUrl
().
replace
(
'_'
,
r'\
_
')),
Query(uid=[x.getUid() for x in follow_up_related_document_list]),
logical_operator='
or
'
)
else:
document_query = Query(relative_url='
%
s
/%%
' % context.getRelativeUrl().replace('
_
', r'
\
_
'))
if query is None:
query = document_query
else:
...
...
@@ -25,4 +33,5 @@ else:
return portal_catalog(
portal_type=portal_type,
query=query,
limit=limit,
**kw)
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