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
alecs_myu
erp5
Commits
70653d64
Commit
70653d64
authored
Sep 20, 2018
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator/Widget.py: Fix LinesField to handle non-string value.
parent
8c33379a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
product/Formulator/Widget.py
product/Formulator/Widget.py
+8
-3
No files found.
product/Formulator/Widget.py
View file @
70653d64
...
...
@@ -48,6 +48,11 @@ class OOoEscaper:
line_break
=
SubElement
(
self
.
parent_node
,
'{%s}%s'
%
(
TEXT_URI
,
'tab'
))
line_break
.
tail
=
match_object
.
group
(
2
)
def
convertToString
(
value
):
if
not
isinstance
(
value
,
(
str
,
unicode
)):
return
str
(
value
)
return
value
class
Widget
:
"""A field widget that knows how to display itself as HTML.
"""
...
...
@@ -702,7 +707,7 @@ class LinesTextAreaWidget(TextAreaWidget):
"""
if
isinstance
(
value
,
(
str
,
unicode
)):
value
=
[
value
]
value
=
string
.
join
(
value
,
"
\
n
"
)
value
=
string
.
join
(
map
(
convertToString
,
value
)
,
"
\
n
"
)
return
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
...
...
@@ -712,7 +717,7 @@ class LinesTextAreaWidget(TextAreaWidget):
value
=
value
.
split
(
'
\
n
'
)
line_separator
=
field
.
get_value
(
'view_separator'
)
value_list
=
[
escape
(
part
).
replace
(
'
\
n
'
,
line_separator
)
for
part
in
value
]
value_list
=
[
escape
(
convertToString
(
part
)
).
replace
(
'
\
n
'
,
line_separator
)
for
part
in
value
]
value
=
line_separator
.
join
(
value_list
)
return
render_element
(
"div"
,
css_class
=
field
.
get_value
(
'css_class'
),
...
...
@@ -726,7 +731,7 @@ class LinesTextAreaWidget(TextAreaWidget):
value
=
[
''
]
elif
isinstance
(
value
,
(
str
,
unicode
)):
value
=
[
value
]
value
=
'
\
n
'
.
join
(
value
)
value
=
'
\
n
'
.
join
(
map
(
convertToString
,
value
)
)
return
TextAreaWidget
.
render_odt_view
(
self
,
field
,
value
,
as_string
,
ooo_builder
,
REQUEST
,
render_prefix
,
attr_dict
,
local_name
)
...
...
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