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
Mikolaï Krol
erp5
Commits
9aa4bc0d
Commit
9aa4bc0d
authored
Feb 04, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web: reuse the web section logic
parent
3d17186c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
73 deletions
+2
-73
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/StaticWebSection_getDocumentValue.py
...ortal_skins/erp5_web/StaticWebSection_getDocumentValue.py
+1
-72
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/StaticWebSection_getDocumentValue.xml
...rtal_skins/erp5_web/StaticWebSection_getDocumentValue.xml
+1
-1
No files found.
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/StaticWebSection_getDocumentValue.py
View file @
9aa4bc0d
"""
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
()
# 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'
),
)
# Portal Type and validation state should be handled by predicate
# By default
document_list
=
context
.
searchResults
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
language
=
(
language
,
''
),
sort_on
=
((
'language'
,
'descending'
),
)
+
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
document_list
)
==
0
:
# Default returns None
document
=
None
else
:
# Try to get the first page on the list
document
=
document_list
[
0
]
document
=
document
.
getObject
()
# return the web page
return
document
return
context
.
WebSection_getDocumentValue
(
name
,
**
kw
)
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/StaticWebSection_getDocumentValue.xml
View file @
9aa4bc0d
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
name,
portal=None, language=None, validation_state=None, effective_date=None, now=None,
**kw
</string>
</value>
<value>
<string>
name, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
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