Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
f36260d2
Commit
f36260d2
authored
Oct 10, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code clean up in ListBox & EditorField
parent
4d1b9357
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
100 deletions
+67
-100
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Workflow_statusModify.xml
...m/portal_skins/erp5_xhtml_style/Workflow_statusModify.xml
+4
-9
product/ERP5Form/EditorField.py
product/ERP5Form/EditorField.py
+13
-19
product/ERP5Form/ListBox.py
product/ERP5Form/ListBox.py
+50
-72
No files found.
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Workflow_statusModify.xml
View file @
f36260d2
...
@@ -94,15 +94,10 @@ for f in form.get_fields():\n
...
@@ -94,15 +94,10 @@ for f in form.get_fields():\n
listbox = request.get(\'listbox\') # XXX: hardcoded field name\n
listbox = request.get(\'listbox\') # XXX: hardcoded field name\n
if listbox is not None:\n
if listbox is not None:\n
listbox_line_list = []\n
listbox_line_list = []\n
listbox = getattr(request,\'listbox\',None) # XXX: hardcoded field name\n
for key, value in sorted(listbox.iteritems()):\n
listbox_keys = listbox.keys()\n
value[\'listbox_key\'] = key\n
listbox_keys.sort()\n
listbox_line_list.append(value)\n
for key in listbox_keys:\n
doaction_param_list[\'listbox\'] = tuple(listbox_line_list)\n
listbox_line = listbox[key]\n
listbox_line[\'listbox_key\'] = key\n
listbox_line_list.append(listbox[key])\n
listbox_line_list = tuple(listbox_line_list)\n
doaction_param_list[\'listbox\'] = listbox_line_list # XXX: hardcoded field name\n
\n
\n
try:\n
try:\n
context.portal_workflow.doActionFor(\n
context.portal_workflow.doActionFor(\n
...
...
product/ERP5Form/EditorField.py
View file @
f36260d2
...
@@ -83,16 +83,13 @@ class EditorWidget(Widget.TextAreaWidget):
...
@@ -83,16 +83,13 @@ class EditorWidget(Widget.TextAreaWidget):
"""
"""
here
=
REQUEST
[
'here'
]
here
=
REQUEST
[
'here'
]
text_editor
=
field
.
get_value
(
'text_editor'
)
text_editor
=
field
.
get_value
(
'text_editor'
)
if
text_editor
==
'text_area'
:
if
text_editor
==
'bespin'
:
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
elif
text_editor
==
'bespin'
:
# XXX The usage of bespin editor depends of erp5_bespin bt5
# XXX The usage of bespin editor depends of erp5_bespin bt5
# installed and still experimental. If erp5_bespin is not installed, it
# installed and still experimental. If erp5_bespin is not installed, it
# render standard an standard editor field.
# render standard an standard editor field.
bespin_support
=
getattr
(
here
,
'bespin_support'
,
None
)
bespin_support
=
getattr
(
here
,
'bespin_support'
,
None
)
if
bespin_support
is
None
:
if
bespin_support
is
not
None
:
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
return
bespin_support
.
pt_render
(
return
bespin_support
.
pt_render
(
extra_context
=
{
extra_context
=
{
'field'
:
field
,
'field'
:
field
,
'inputvalue'
:
value
,
'inputvalue'
:
value
,
...
@@ -100,9 +97,8 @@ class EditorWidget(Widget.TextAreaWidget):
...
@@ -100,9 +97,8 @@ class EditorWidget(Widget.TextAreaWidget):
})
})
elif
text_editor
==
"xinha"
:
elif
text_editor
==
"xinha"
:
xinha_support
=
getattr
(
here
,
'xinha_support'
,
None
)
xinha_support
=
getattr
(
here
,
'xinha_support'
,
None
)
if
xinha_support
is
None
:
if
xinha_support
is
not
None
:
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
return
xinha_support
.
pt_render
(
return
xinha_support
.
pt_render
(
extra_context
=
{
extra_context
=
{
'field'
:
field
,
'field'
:
field
,
'field_value'
:
value
,
'field_value'
:
value
,
...
@@ -110,27 +106,25 @@ class EditorWidget(Widget.TextAreaWidget):
...
@@ -110,27 +106,25 @@ class EditorWidget(Widget.TextAreaWidget):
})
})
elif
text_editor
==
"svg_editor"
:
elif
text_editor
==
"svg_editor"
:
svg_editor_support
=
getattr
(
here
,
'svg_editor_support'
,
None
)
svg_editor_support
=
getattr
(
here
,
'svg_editor_support'
,
None
)
if
svg_editor_support
is
None
:
if
svg_editor_support
is
not
None
:
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
return
svg_editor_support
.
pt_render
()
return
svg_editor_support
.
pt_render
()
elif
text_editor
==
"spreadsheet_editor"
:
elif
text_editor
==
"spreadsheet_editor"
:
sheet_editor_support
=
getattr
(
here
,
'sheet_editor_support'
,
None
)
sheet_editor_support
=
getattr
(
here
,
'sheet_editor_support'
,
None
)
if
sheet_editor_support
is
None
:
if
sheet_editor_support
is
not
None
:
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
return
sheet_editor_support
.
pt_render
()
return
sheet_editor_support
.
pt_render
()
elif
text_editor
==
'ace'
:
elif
text_editor
==
'ace'
:
ace_editor_support
=
getattr
(
here
,
'ace_editor_support'
,
None
)
ace_editor_support
=
getattr
(
here
,
'ace_editor_support'
,
None
)
if
ace_editor_support
is
None
:
if
ace_editor_support
is
not
None
:
return
Widget
.
TextAreaWidth
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
return
ace_editor_support
.
pt_render
(
extra_context
=
{
'field'
:
field
,
return
ace_editor_support
.
pt_render
(
extra_context
=
{
'field'
:
field
,
'content'
:
value
,
'content'
:
value
,
'id'
:
key
})
'id'
:
key
})
el
se
:
el
if
text_editor
!=
'text_area'
:
return
here
.
fckeditor_wysiwyg_support
.
pt_render
(
return
here
.
fckeditor_wysiwyg_support
.
pt_render
(
extra_context
=
{
extra_context
=
{
'inputvalue'
:
value
,
'inputvalue'
:
value
,
'inputname'
:
key
'inputname'
:
key
})
})
return
Widget
.
TextAreaWidget
.
render
(
self
,
field
,
key
,
value
,
REQUEST
)
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
"""
"""
...
...
product/ERP5Form/ListBox.py
View file @
f36260d2
...
@@ -2746,7 +2746,7 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2746,7 +2746,7 @@ class ListBoxValidator(Validator.Validator):
editable_columns
=
field
.
get_value
(
'editable_columns'
)
editable_columns
=
field
.
get_value
(
'editable_columns'
)
column_ids
=
[
x
[
0
]
for
x
in
columns
]
column_ids
=
[
x
[
0
]
for
x
in
columns
]
editable_column_ids
=
[
x
[
0
]
for
x
in
editable_columns
]
editable_column_ids
=
[
x
[
0
]
for
x
in
editable_columns
]
editable_field_dict
=
dict
()
editable_field_dict
=
{}
for
sql
in
editable_column_ids
:
for
sql
in
editable_column_ids
:
alias
=
sql
.
replace
(
'.'
,
'_'
)
alias
=
sql
.
replace
(
'.'
,
'_'
)
editable_field_dict
[
alias
]
=
ListBoxRenderer
(
editable_field_dict
[
alias
]
=
ListBoxRenderer
(
...
@@ -2754,55 +2754,49 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2754,55 +2754,49 @@ class ListBoxValidator(Validator.Validator):
selection_name
=
field
.
get_value
(
'selection_name'
)
selection_name
=
field
.
get_value
(
'selection_name'
)
#LOG('ListBoxValidator', 0, 'field = %s, selection_name = %s' % (repr(field), repr(selection_name)))
#LOG('ListBoxValidator', 0, 'field = %s, selection_name = %s' % (repr(field), repr(selection_name)))
params
=
here
.
portal_selections
.
getSelectionParamsFor
(
portal
=
here
.
getPortalObject
()
params
=
portal
.
portal_selections
.
getSelectionParamsFor
(
selection_name
,
selection_name
,
REQUEST
=
REQUEST
)
REQUEST
=
REQUEST
)
portal_url
=
getToolByName
(
here
,
'portal_url'
)
portal_url
=
portal
.
portal_url
portal
=
portal_url
.
getPortalObject
()
result
=
{}
result
=
{}
error_result
=
{}
error_result
=
{}
MARKER
=
[]
try
:
listbox_uids
=
REQUEST
.
get
(
'%s_uid'
%
field
.
id
,
MARKER
)
listbox_uids
=
REQUEST
[
'%s_uid'
%
field
.
id
]
if
listbox_uids
is
MARKER
:
except
KeyError
:
raise
KeyError
,
'Field %s is not present in request object.'
%
(
field
.
id
,
)
raise
KeyError
(
'Field %s is not present in request object.'
%
field
.
id
)
#LOG('ListBox.validate: REQUEST',0,REQUEST)
#LOG('ListBox.validate: REQUEST',0,REQUEST)
errors
=
[]
errors
=
[]
object_list
=
[]
object_list
=
None
# We have two things to do in the case of temp objects,
# We have two things to do in the case of temp objects,
# the first thing is to create a list with new temp objects
# the first thing is to create a list with new temp objects
# then try to validate some data, and then create again
# then try to validate some data, and then create again
# the list with a listbox as parameter. Like this we
# the list with a listbox as parameter. Like this we
# can use tales expression
# can use tales expression
for
uid
in
listbox_uids
:
if
str
(
uid
).
find
(
'new'
)
==
0
:
list_method
=
field
.
get_value
(
'list_method'
)
list_method
=
getattr
(
here
,
list_method
.
method_name
)
#LOG('ListBoxValidator', 0, 'call %s' % repr(list_method))
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
break
listbox
=
{}
listbox
=
{}
for
uid
in
listbox_uids
:
for
uid
in
listbox_uids
:
if
str
(
uid
).
find
(
'new'
)
==
0
:
if
uid
[:
4
]
==
'new_'
:
o
=
None
if
object_list
is
None
:
for
object
in
object_list
:
list_method
=
field
.
get_value
(
'list_method'
)
if
object
.
getUid
()
==
uid
:
list_method
=
getattr
(
here
,
list_method
.
method_name
)
o
=
object
#LOG('ListBoxValidator', 0, 'call %s' % repr(list_method))
if
o
is
None
:
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
row_key
=
uid
[
4
:]
for
o
in
object_list
:
if
o
.
getUid
()
==
uid
:
break
else
:
# First case: dialog input to create new objects
# First case: dialog input to create new objects
o
=
newTempBase
(
portal
,
uid
[
4
:]
)
# Arghhh - XXX acquisition problem - use portal root
o
=
newTempBase
(
portal
,
row_key
)
# Arghhh - XXX acquisition problem - use portal root
o
.
uid
=
uid
o
.
uid
=
uid
listbox
[
uid
[
4
:]]
=
{}
listbox
[
row_key
]
=
row_result
=
{}
# We first try to set a listbox corresponding to all things
# We first try to set a listbox corresponding to all things
# we can validate, so that we can use the same list
# we can validate, so that we can use the same list
# as the one used for displaying the listbox
# as the one used for displaying the listbox
for
sql
in
editable_column_ids
:
for
sql
in
editable_column_ids
:
alias
=
sql
.
replace
(
'.'
,
'_'
)
editable_field
=
editable_field_dict
.
get
(
sql
.
replace
(
'.'
,
'_'
))
if
'.'
in
sql
:
property_id
=
'.'
.
join
(
sql
.
split
(
'.'
)[
1
:])
# Only take trailing part
else
:
property_id
=
alias
editable_field
=
editable_field_dict
.
get
(
alias
)
if
editable_field
is
not
None
:
if
editable_field
is
not
None
:
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
key
=
'field_'
+
error_result_key
key
=
'field_'
+
error_result_key
...
@@ -2810,39 +2804,31 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2810,39 +2804,31 @@ class ListBoxValidator(Validator.Validator):
try
:
try
:
value
=
editable_field
.
_validate_helper
(
key
,
REQUEST
)
# We need cell
value
=
editable_field
.
_validate_helper
(
key
,
REQUEST
)
# We need cell
# Here we set the property
# Here we set the property
listbox
[
uid
[
4
:]]
[
sql
]
=
value
row_result
[
sql
]
=
value
except
ValidationError
,
err
:
except
ValidationError
,
err
:
pass
pass
except
KeyError
:
except
KeyError
:
pass
pass
# Here we generate again the object_list with listbox the listbox we
# Here we generate again the object_list with listbox the listbox we
# have just created
# have just created
if
l
en
(
listbox
)
>
0
:
if
l
istbox
:
list_method
=
field
.
get_value
(
'list_method'
)
list_method
=
field
.
get_value
(
'list_method'
)
list_method
=
getattr
(
here
,
list_method
.
method_name
)
list_method
=
getattr
(
here
,
list_method
.
method_name
)
REQUEST
.
set
(
field
.
id
,
listbox
)
REQUEST
.
set
(
field
.
id
,
listbox
)
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
for
uid
in
listbox_uids
:
for
uid
in
listbox_uids
:
if
str
(
uid
).
find
(
'new'
)
==
0
:
row_result
=
{}
if
uid
[:
4
]
==
'new_'
:
# First case: dialog input to create new objects
# First case: dialog input to create new objects
#o = newTempBase(here, uid[4:]) # Arghhh - XXX acquisition problem - use portal root
row_key
=
uid
[
4
:]
#o.uid = uid
for
o
in
object_list
:
o
=
None
if
o
.
getUid
()
==
uid
:
for
object
in
object_list
:
break
if
object
.
getUid
()
==
uid
:
else
:
o
=
object
o
=
newTempBase
(
portal
,
row_key
)
# Arghhh - XXX acquisition problem - use portal root
if
o
is
None
:
# First case: dialog input to create new objects
o
=
newTempBase
(
portal
,
uid
[
4
:])
# Arghhh - XXX acquisition problem - use portal root
o
.
uid
=
uid
o
.
uid
=
uid
result
[
uid
[
4
:]]
=
{}
for
sql
in
editable_column_ids
:
for
sql
in
editable_column_ids
:
alias
=
sql
.
replace
(
'.'
,
'_'
)
editable_field
=
editable_field_dict
.
get
(
sql
.
replace
(
'.'
,
'_'
))
if
'.'
in
sql
:
property_id
=
'.'
.
join
(
sql
.
split
(
'.'
)[
1
:])
# Only take trailing part
else
:
property_id
=
alias
editable_field
=
editable_field_dict
.
get
(
alias
)
if
editable_field
is
not
None
:
if
editable_field
is
not
None
:
REQUEST
.
set
(
'cell'
,
o
)
REQUEST
.
set
(
'cell'
,
o
)
editable
=
editable_field
.
get_value
(
'editable'
,
REQUEST
=
REQUEST
)
editable
=
editable_field
.
get_value
(
'editable'
,
REQUEST
=
REQUEST
)
...
@@ -2851,8 +2837,8 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2851,8 +2837,8 @@ class ListBoxValidator(Validator.Validator):
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
key
=
'field_'
+
error_result_key
key
=
'field_'
+
error_result_key
try
:
try
:
value
=
editable_field
.
_validate_helper
(
key
,
REQUEST
)
# We need cell
row_result
[
sql
]
=
editable_field
.
_validate_helper
(
result
[
uid
[
4
:]][
sql
]
=
value
key
,
REQUEST
)
# We need cell
except
ValidationError
,
err
:
except
ValidationError
,
err
:
#LOG("ListBox ValidationError",0,str(err))
#LOG("ListBox ValidationError",0,str(err))
err
.
field_id
=
error_result_key
err
.
field_id
=
error_result_key
...
@@ -2869,43 +2855,34 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2869,43 +2855,34 @@ class ListBoxValidator(Validator.Validator):
# because sometimes, we can be provided bad uids
# because sometimes, we can be provided bad uids
try
:
try
:
o
=
here
.
portal_catalog
.
getObject
(
uid
)
o
=
here
.
portal_catalog
.
getObject
(
uid
)
except
(
KeyError
,
NotFound
,
ValueError
):
except
(
KeyError
,
NotFound
,
ValueError
),
err
:
o
=
None
if
o
is
None
:
# It is possible that this object is not catalogged yet. So
# It is possible that this object is not catalogged yet. So
# the object must be obtained from ZODB.
# the object must be obtained from ZODB.
if
not
object_list
:
if
object_list
is
None
:
list_method
=
field
.
get_value
(
'list_method'
)
list_method
=
field
.
get_value
(
'list_method'
)
list_method
=
getattr
(
here
,
list_method
.
method_name
)
list_method
=
getattr
(
here
,
list_method
.
method_name
)
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
object_list
=
list_method
(
REQUEST
=
REQUEST
,
**
params
)
for
o
bject
in
object_list
:
for
o
in
object_list
:
try
:
try
:
if
object
.
getUid
()
==
int
(
uid
):
if
o
.
getUid
()
==
int
(
uid
):
o
=
object
break
break
except
ValueError
:
except
ValueError
:
if
str
(
object
.
getUid
())
==
uid
:
if
str
(
object
.
getUid
())
==
uid
:
o
=
object
break
break
for
sql
in
editable_column_ids
:
alias
=
sql
.
replace
(
'.'
,
'_'
)
if
'.'
in
sql
:
property_id
=
'.'
.
join
(
sql
.
split
(
'.'
)[
1
:])
# Only take trailing part
else
:
else
:
property_id
=
alias
raise
err
editable_field
=
editable_field_dict
.
get
(
alias
)
row_key
=
o
.
getUrl
()
for
sql
in
editable_column_ids
:
editable_field
=
editable_field_dict
.
get
(
sql
.
replace
(
'.'
,
'_'
))
if
editable_field
is
not
None
:
if
editable_field
is
not
None
:
REQUEST
.
set
(
'cell'
,
o
)
# We need cell
REQUEST
.
set
(
'cell'
,
o
)
# We need cell
if
editable_field
.
get_value
(
'editable'
,
REQUEST
=
REQUEST
)
\
if
editable_field
.
get_value
(
'editable'
,
REQUEST
=
REQUEST
)
and
\
and
field
.
need_validate
(
REQUEST
):
editable_
field
.
need_validate
(
REQUEST
):
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
error_result_key
=
'%s_%s'
%
(
editable_field
.
id
,
o
.
uid
)
key
=
'field_'
+
error_result_key
key
=
'field_'
+
error_result_key
try
:
try
:
value
=
editable_field
.
_validate_helper
(
key
,
REQUEST
)
row_result
[
sql
]
=
error_result
[
error_result_key
]
=
\
error_result
[
error_result_key
]
=
value
editable_field
.
_validate_helper
(
key
,
REQUEST
)
if
not
result
.
has_key
(
o
.
getUrl
()):
result
[
o
.
getUrl
()]
=
{}
result
[
o
.
getUrl
()][
sql
]
=
value
except
ValidationError
,
err
:
except
ValidationError
,
err
:
err
.
field_id
=
error_result_key
err
.
field_id
=
error_result_key
errors
.
append
(
err
)
errors
.
append
(
err
)
...
@@ -2916,6 +2893,7 @@ class ListBoxValidator(Validator.Validator):
...
@@ -2916,6 +2893,7 @@ class ListBoxValidator(Validator.Validator):
#except:
#except:
else
:
else
:
LOG
(
"ListBox WARNING"
,
0
,
"Object uid %s could not be validated"
%
uid
)
LOG
(
"ListBox WARNING"
,
0
,
"Object uid %s could not be validated"
%
uid
)
result
[
row_key
]
=
row_result
if
len
(
errors
)
>
0
:
if
len
(
errors
)
>
0
:
#LOG("ListBox FormValidationError",0,str(error_result))
#LOG("ListBox FormValidationError",0,str(error_result))
#LOG("ListBox FormValidationError",0,str(errors))
#LOG("ListBox FormValidationError",0,str(errors))
...
...
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