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
Levin Zimmermann
erp5
Commits
10ad0fce
Commit
10ad0fce
authored
Apr 25, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: ListBox.
parent
f5842fd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
21 deletions
+53
-21
product/ERP5Form/ListBox.py
product/ERP5Form/ListBox.py
+53
-21
No files found.
product/ERP5Form/ListBox.py
View file @
10ad0fce
...
@@ -55,6 +55,7 @@ from Products.PythonScripts.Utility import allow_class
...
@@ -55,6 +55,7 @@ from Products.PythonScripts.Utility import allow_class
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
warnings
import
warn
from
warnings
import
warn
import
cgi
import
cgi
import
six
DEFAULT_LISTBOX_DISPLAY_STYLE
=
'table'
DEFAULT_LISTBOX_DISPLAY_STYLE
=
'table'
DEFAULT_LISTBOX_PAGE_NAVIGATION_TEMPLATE
=
'ListBox_viewSliderPageNavigationRenderer'
DEFAULT_LISTBOX_PAGE_NAVIGATION_TEMPLATE
=
'ListBox_viewSliderPageNavigationRenderer'
...
@@ -669,7 +670,10 @@ class ListBoxRenderer:
...
@@ -669,7 +670,10 @@ class ListBoxRenderer:
def
getTitle
(
self
):
def
getTitle
(
self
):
"""Return the title. Make sure that it is in unicode.
"""Return the title. Make sure that it is in unicode.
"""
"""
return
unicode
(
self
.
field
.
get_value
(
'title'
),
self
.
getEncoding
())
if
six
.
PY2
:
return
unicode
(
self
.
field
.
get_value
(
'title'
),
self
.
getEncoding
())
else
:
return
self
.
field
.
get_value
(
'title'
)
def
getMaxLineNumber
(
self
):
def
getMaxLineNumber
(
self
):
"""Return the maximum number of lines shown in a page.
"""Return the maximum number of lines shown in a page.
...
@@ -858,7 +862,10 @@ class ListBoxRenderer:
...
@@ -858,7 +862,10 @@ class ListBoxRenderer:
"""Return the columns. Make sure that the titles are in unicode.
"""Return the columns. Make sure that the titles are in unicode.
"""
"""
columns
=
self
.
field
.
get_value
(
'columns'
)
columns
=
self
.
field
.
get_value
(
'columns'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
if
six
.
PY3
:
return
columns
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
@
lazyMethod
@
lazyMethod
def
getAllColumnList
(
self
):
def
getAllColumnList
(
self
):
...
@@ -867,9 +874,14 @@ class ListBoxRenderer:
...
@@ -867,9 +874,14 @@ class ListBoxRenderer:
"""
"""
all_column_list
=
list
(
self
.
getColumnList
())
all_column_list
=
list
(
self
.
getColumnList
())
all_column_id_set
=
{
c
[
0
]
for
c
in
all_column_list
}
all_column_id_set
=
{
c
[
0
]
for
c
in
all_column_list
}
all_column_list
.
extend
((
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
if
six
.
PY3
:
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
all_column_list
.
extend
(
c
if
c
[
0
]
not
in
all_column_id_set
)
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
if
c
[
0
]
not
in
all_column_id_set
)
else
:
all_column_list
.
extend
((
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
if
c
[
0
]
not
in
all_column_id_set
)
return
all_column_list
return
all_column_list
@
lazyMethod
@
lazyMethod
...
@@ -884,7 +896,10 @@ class ListBoxRenderer:
...
@@ -884,7 +896,10 @@ class ListBoxRenderer:
"""
"""
stat_columns
=
self
.
field
.
get_value
(
'stat_columns'
)
stat_columns
=
self
.
field
.
get_value
(
'stat_columns'
)
if
stat_columns
:
if
stat_columns
:
stat_column_list
=
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
stat_columns
]
if
six
.
PY3
:
stat_column_list
=
stat_columns
else
:
stat_column_list
=
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
stat_columns
]
else
:
else
:
stat_column_list
=
[(
c
[
0
],
c
[
0
])
for
c
in
self
.
getAllColumnList
()]
stat_column_list
=
[(
c
[
0
],
c
[
0
])
for
c
in
self
.
getAllColumnList
()]
return
stat_column_list
return
stat_column_list
...
@@ -914,21 +929,30 @@ class ListBoxRenderer:
...
@@ -914,21 +929,30 @@ class ListBoxRenderer:
"""Return the domain root list. Make sure that the titles are in unicode.
"""Return the domain root list. Make sure that the titles are in unicode.
"""
"""
domain_root_list
=
self
.
field
.
get_value
(
'domain_root_list'
)
domain_root_list
=
self
.
field
.
get_value
(
'domain_root_list'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
if
six
.
PY3
:
return
domain_root_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
@
lazyMethod
@
lazyMethod
def
getReportRootList
(
self
):
def
getReportRootList
(
self
):
"""Return the report root list. Make sure that the titles are in unicode.
"""Return the report root list. Make sure that the titles are in unicode.
"""
"""
report_root_list
=
self
.
field
.
get_value
(
'report_root_list'
)
report_root_list
=
self
.
field
.
get_value
(
'report_root_list'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
if
six
.
PY3
:
return
report_root_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
@
lazyMethod
@
lazyMethod
def
getDisplayStyleList
(
self
):
def
getDisplayStyleList
(
self
):
"""Return the list of avaible display style. Make sure that the
"""Return the list of avaible display style. Make sure that the
titles are in unicode"""
titles are in unicode"""
display_style_list
=
self
.
field
.
get_value
(
'display_style_list'
)
display_style_list
=
self
.
field
.
get_value
(
'display_style_list'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
if
six
.
PY3
:
return
display_style_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
display_style_list
]
display_style_list
]
@
lazyMethod
@
lazyMethod
...
@@ -1603,8 +1627,8 @@ class ListBoxRenderer:
...
@@ -1603,8 +1627,8 @@ class ListBoxRenderer:
param
=
param_dict
.
get
(
alias
,
param_dict
.
get
(
sql
,
u''
))
param
=
param_dict
.
get
(
alias
,
param_dict
.
get
(
sql
,
u''
))
if
isinstance
(
param
,
dict
):
if
isinstance
(
param
,
dict
):
param
=
param
.
get
(
'query'
,
u''
)
param
=
param
.
get
(
'query'
,
u''
)
if
isinstance
(
param
,
s
tr
):
if
isinstance
(
param
,
s
ix
.
binary_type
):
param
=
unicode
(
param
,
self
.
getEncoding
())
param
=
param
.
decode
(
self
.
getEncoding
())
# Obtain a search field, if any.
# Obtain a search field, if any.
form
=
self
.
getForm
()
form
=
self
.
getForm
()
...
@@ -1686,8 +1710,12 @@ class ListBoxRenderer:
...
@@ -1686,8 +1710,12 @@ class ListBoxRenderer:
if
editable_field
is
not
None
:
if
editable_field
is
not
None
:
processed_value
=
editable_field
.
render_view
(
value
=
original_value
)
processed_value
=
editable_field
.
render_view
(
value
=
original_value
)
if
not
isinstance
(
processed_value
,
unicode
):
if
not
isinstance
(
processed_value
,
six
.
text_type
):
processed_value
=
unicode
(
str
(
processed_value
),
self
.
getEncoding
(),
'replace'
)
if
six
.
PY3
:
processed_value
=
str
(
processed_value
).
encode
(
self
.
getEncoding
(),
'replace'
).
decode
()
else
:
processed_value
=
unicode
(
str
(
processed_value
),
self
.
getEncoding
(),
'replace'
)
value_list
.
append
((
original_value
,
processed_value
))
value_list
.
append
((
original_value
,
processed_value
))
...
@@ -2280,8 +2308,12 @@ class ListBoxRendererLine:
...
@@ -2280,8 +2308,12 @@ class ListBoxRendererLine:
# Process the value.
# Process the value.
if
processed_value
is
None
:
if
processed_value
is
None
:
processed_value
=
u''
processed_value
=
u''
elif
not
isinstance
(
processed_value
,
unicode
):
elif
not
isinstance
(
processed_value
,
six
.
text_type
):
processed_value
=
unicode
(
str
(
processed_value
),
renderer
.
getEncoding
(),
'replace'
)
if
six
.
PY3
:
processed_value
=
str
(
processed_value
).
encode
(
renderer
.
getEncoding
(),
'replace'
).
decode
()
else
:
processed_value
=
unicode
(
str
(
processed_value
),
renderer
.
getEncoding
(),
'replace'
)
value_list
.
append
((
original_value
,
processed_value
))
value_list
.
append
((
original_value
,
processed_value
))
...
@@ -2395,8 +2427,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
...
@@ -2395,8 +2427,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
except
AttributeError
:
except
AttributeError
:
pass
pass
if
isinstance
(
url
,
s
tr
):
if
isinstance
(
url
,
s
ix
.
binary_type
):
url
=
unicode
(
url
,
encoding
)
url
=
str
(
url
,
encoding
)
if
editable_field
is
not
None
:
if
editable_field
is
not
None
:
uid
=
self
.
getUid
()
uid
=
self
.
getUid
()
...
@@ -2459,8 +2491,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
...
@@ -2459,8 +2491,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
editable
=
(
not
self
.
isSummary
())
\
editable
=
(
not
self
.
isSummary
())
\
and
listbox_defines_column_as_editable
and
editable
,
and
listbox_defines_column_as_editable
and
editable
,
)
)
if
isinstance
(
cell_html
,
s
tr
):
if
isinstance
(
cell_html
,
s
ix
.
binary_type
):
cell_html
=
unicode
(
cell_html
,
encoding
)
cell_html
=
str
(
cell_html
,
encoding
)
else
:
else
:
cell_html
=
u''
cell_html
=
u''
...
@@ -2661,7 +2693,7 @@ class ListBoxListRenderer(ListBoxRenderer):
...
@@ -2661,7 +2693,7 @@ class ListBoxListRenderer(ListBoxRenderer):
listboxline
.
checkLine
(
uid
in
checked_uid_set
)
listboxline
.
checkLine
(
uid
in
checked_uid_set
)
for
(
original_value
,
processed_value
),
(
sql
,
title
)
in
zip
(
line
.
getValueList
(),
self
.
getSelectedColumnList
()):
for
(
original_value
,
processed_value
),
(
sql
,
title
)
in
zip
(
line
.
getValueList
(),
self
.
getSelectedColumnList
()):
if
isinstance
(
original_value
,
unicod
e
):
if
isinstance
(
original_value
,
six
.
text_typ
e
):
value
=
original_value
.
encode
(
self
.
getEncoding
())
value
=
original_value
.
encode
(
self
.
getEncoding
())
else
:
else
:
value
=
original_value
value
=
original_value
...
@@ -2679,7 +2711,7 @@ class ListBoxListRenderer(ListBoxRenderer):
...
@@ -2679,7 +2711,7 @@ class ListBoxListRenderer(ListBoxRenderer):
stat_listboxline
.
markStatLine
()
stat_listboxline
.
markStatLine
()
for
(
original_value
,
processed_value
),
(
sql
,
title
)
in
zip
(
self
.
getStatValueList
(),
self
.
getSelectedColumnList
()):
for
(
original_value
,
processed_value
),
(
sql
,
title
)
in
zip
(
self
.
getStatValueList
(),
self
.
getSelectedColumnList
()):
if
isinstance
(
original_value
,
unicod
e
):
if
isinstance
(
original_value
,
six
.
text_typ
e
):
value
=
original_value
.
encode
(
self
.
getEncoding
())
value
=
original_value
.
encode
(
self
.
getEncoding
())
else
:
else
:
value
=
original_value
value
=
original_value
...
...
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