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
044d8f38
Commit
044d8f38
authored
Jun 28, 2019
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: remove abbreviations in Base_edit
parent
75c9a1a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
54 deletions
+54
-54
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
...core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
+54
-54
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
View file @
044d8f38
...
...
@@ -42,8 +42,8 @@ except FormValidationError, validation_errors:
field_errors
=
form
.
ErrorFields
(
validation_errors
)
request
.
set
(
'field_errors'
,
field_errors
)
# Make sure editors are pushed back as values into the REQUEST object
for
f
in
form
.
get_fields
():
field_id
=
f
.
id
for
f
ield
in
form
.
get_fields
():
field_id
=
f
ield
.
id
if
request
.
has_key
(
field_id
):
value
=
request
.
get
(
field_id
)
if
callable
(
value
):
...
...
@@ -55,30 +55,30 @@ def editListBox(listbox_field, listbox):
""" Function called to edit a listbox
"""
if
listbox
is
not
None
:
g
v
=
{}
g
lobal_property_dict
=
{}
if
listbox_field
.
has_value
(
'global_attributes'
):
hidden_attribute
s
=
map
(
lambda
x
:
x
[
0
],
listbox_field
.
get_value
(
'global_attributes'
))
for
k
in
hidden_attributes
:
g
v
[
k
]
=
getattr
(
request
,
k
,
None
)
for
url
,
v
in
listbox
.
items
():
v
.
update
(
gv
)
hidden_attribute
_list
=
map
(
lambda
x
:
x
[
0
],
listbox_field
.
get_value
(
'global_attributes'
))
for
hidden_attribute
in
hidden_attribute_list
:
g
lobal_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
for
item_url
,
listbox_item_dict
in
listbox
.
items
():
listbox_item_dict
.
update
(
global_property_dict
)
# Form: '' -> ERP5: None
encapsulated_editor_list
=
[]
cleaned_v
=
{}
for
key
,
value
in
v
.
items
():
for
key
,
value
in
listbox_item_dict
.
items
():
if
hasattr
(
value
,
'edit'
):
encapsulated_editor_list
.
append
(
value
)
else
:
if
value
==
''
:
if
value
==
''
:
value
=
None
cleaned_v
[
key
]
=
value
if
cleaned_v
:
if
listbox_edit
is
None
:
obj
=
context
.
restrictedTraverse
(
url
)
obj
=
context
.
restrictedTraverse
(
item_
url
)
obj
.
edit
(
edit_order
=
edit_order
,
**
cleaned_v
)
else
:
listbox_edit
(
url
,
edit_order
,
cleaned_v
)
listbox_edit
(
item_
url
,
edit_order
,
cleaned_v
)
for
encapsulated_editor
in
encapsulated_editor_list
:
encapsulated_editor
.
edit
(
obj
)
...
...
@@ -95,14 +95,14 @@ def editMatrixBox(matrixbox_field, matrixbox):
else
:
matrix_context
=
context
if
matrix_context
is
not
None
:
k
d
=
{}
k
d
[
'portal_type'
]
=
portal_type
k
d
[
'base_id'
]
=
cell_base_id
g
v
=
{}
k
_dict
=
{}
k
_dict
[
'portal_type'
]
=
portal_type
k
_dict
[
'base_id'
]
=
cell_base_id
g
lobal_property_dict
=
{}
if
matrixbox_field
.
has_value
(
'global_attributes'
):
hidden_attribute
s
=
[
x
[
0
]
for
x
in
matrixbox_field
.
get_value
(
'global_attributes'
)]
for
k
in
hidden_attributes
:
g
v
[
k
]
=
getattr
(
request
,
k
,
None
)
hidden_attribute
_list
=
[
x
[
0
]
for
x
in
matrixbox_field
.
get_value
(
'global_attributes'
)]
for
hidden_attribute
in
hidden_attribute_list
:
g
lobal_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
if
matrixbox_field
.
get_value
(
'update_cell_range'
):
as_cell_range_script_id
=
matrixbox_field
.
get_value
(
'as_cell_range_script_id'
)
...
...
@@ -157,57 +157,57 @@ def editMatrixBox(matrixbox_field, matrixbox):
if
cell_range
!=
matrixbox_cell_range
:
matrix_context
.
setCellRange
(
base_id
=
cell_base_id
,
*
matrixbox_cell_range
)
for
k
,
v
in
matrixbox
.
items
():
for
cell_index_tuple
,
cell_dict
in
matrixbox
.
items
():
# Only update cells which still exist
if
matrix_context
.
hasInRange
(
*
k
,
**
kd
):
c
=
matrix_context
.
newCell
(
*
k
,
**
kd
)
if
c
is
not
None
:
c
.
edit
(
edit_order
=
edit_order
,
**
gv
)
# First update globals which include the def. of property_list
if
v
.
has_key
(
'variated_property'
):
if
matrix_context
.
hasInRange
(
*
cell_index_tuple
,
**
k_dict
):
c
ell
=
matrix_context
.
newCell
(
*
cell_index_tuple
,
**
k_dict
)
if
c
ell
is
not
None
:
c
ell
.
edit
(
edit_order
=
edit_order
,
**
global_property_dict
)
# First update globals which include the def. of property_list
if
cell_dict
.
has_key
(
'variated_property'
):
# For Variated Properties
va
lue
=
v
[
'variated_property'
]
del
v
[
'variated_property'
]
if
g
v
.
has_key
(
'mapped_value_property_list'
):
va
riated_property
=
cell_dict
[
'variated_property'
]
del
cell_dict
[
'variated_property'
]
if
g
lobal_property_dict
.
has_key
(
'mapped_value_property_list'
):
# Change the property which is defined by the
# first element of mapped_value_property_list
# XXX May require some changes with Sets
key
=
g
v
[
'mapped_value_property_list'
][
0
]
v
[
key
]
=
value
key
=
g
lobal_property_dict
[
'mapped_value_property_list'
][
0
]
cell_dict
[
key
]
=
variated_property
# Form: '' -> ERP5: None
cleaned_v
=
v
.
copy
()
cleaned_v
=
cell_dict
.
copy
()
for
key
,
value
in
cleaned_v
.
items
():
if
value
==
''
:
cleaned_v
[
key
]
=
None
c
.
edit
(
edit_order
=
edit_order
,
**
cleaned_v
)
# and update the cell specific values
c
ell
.
edit
(
edit_order
=
edit_order
,
**
cleaned_v
)
# and update the cell specific values
else
:
return
"Could not create cell %s"
%
str
(
k
)
return
"Could not create cell %s"
%
str
(
cell_index_tuple
)
else
:
return
"Cell %s does not exist"
%
str
(
k
)
return
"Cell %s does not exist"
%
str
(
cell_index_tuple
)
field_prefix_len
=
len
(
field_prefix
)
def
parseField
(
f
):
def
parseField
(
f
ield
):
"""
Parse given form field, to put them in
kw or in encapsulated_editor_list
"""
k
=
f
.
id
if
f
.
has_value
(
'alternate_name'
):
k
=
f
.
get_value
(
'alternate_name'
)
or
f
.
id
v
=
getattr
(
request
,
k
,
MARKER
)
if
hasattr
(
v
,
'edit'
):
field_id
=
field
.
id
if
f
ield
.
has_value
(
'alternate_name'
):
field_id
=
field
.
get_value
(
'alternate_name'
)
or
field_
id
v
alue
=
getattr
(
request
,
field_id
,
MARKER
)
if
hasattr
(
v
alue
,
'edit'
):
# This is an encapsulated editor
# call it
encapsulated_editor_list
.
append
(
v
)
elif
v
is
not
MARKER
:
if
k
.
startswith
(
field_prefix
):
encapsulated_editor_list
.
append
(
v
alue
)
elif
v
alue
is
not
MARKER
:
if
field_id
.
startswith
(
field_prefix
):
# We only take into account
# the object attributes
k
=
k
[
field_prefix_len
:]
field_id
=
field_id
[
field_prefix_len
:]
# Form: '' -> ERP5: None
if
v
==
''
:
v
=
None
kw
[
k
]
=
v
if
v
alue
==
''
:
v
alue
=
None
kw
[
field_id
]
=
value
# Some initilizations
kw
=
{}
...
...
@@ -232,7 +232,7 @@ for field in form.get_fields():
elif
(
field_meta_type
==
'MatrixBox'
):
editMatrixBox
(
field
,
request
.
get
(
field
.
id
))
# Return parsed values
# Return parsed values
if
silent_mode
:
return
(
kw
,
encapsulated_editor_list
),
'edit'
# Maybe we should build a list of objects we need
...
...
@@ -246,12 +246,12 @@ if message_only:
ignore_layout
=
int
(
ignore_layout
)
editable_mode
=
int
(
editable_mode
)
s
pp
=
context
.
getPhysicalPath
()
s
pp
=
list
(
spp
)
s_url
=
request
[
"SERVER_URL"
]
s
pp
.
insert
(
0
,
s
_url
)
s
erver_physical_path
=
context
.
getPhysicalPath
()
s
erver_physical_path
=
list
(
server_physical_path
)
s
erver
_url
=
request
[
"SERVER_URL"
]
s
erver_physical_path
.
insert
(
0
,
server
_url
)
#calculate direct the url instead of using absolute_url
new_url
=
'/'
.
join
(
s
pp
)
new_url
=
'/'
.
join
(
s
erver_physical_path
)
# for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'.
...
...
@@ -275,7 +275,7 @@ redirect_url = '%s/%s?%s' % (
make_query
(
**
redirect_url_kw
)
)
result
=
request
[
'RESPONSE'
].
redirect
(
redirect_url
)
result
=
request
[
'RESPONSE'
].
redirect
(
redirect_url
)
if
silent_mode
:
return
result
,
'redirect'
return
result
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