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
Binh
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
Show 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:
...
@@ -42,8 +42,8 @@ except FormValidationError, validation_errors:
field_errors
=
form
.
ErrorFields
(
validation_errors
)
field_errors
=
form
.
ErrorFields
(
validation_errors
)
request
.
set
(
'field_errors'
,
field_errors
)
request
.
set
(
'field_errors'
,
field_errors
)
# Make sure editors are pushed back as values into the REQUEST object
# Make sure editors are pushed back as values into the REQUEST object
for
f
in
form
.
get_fields
():
for
f
ield
in
form
.
get_fields
():
field_id
=
f
.
id
field_id
=
f
ield
.
id
if
request
.
has_key
(
field_id
):
if
request
.
has_key
(
field_id
):
value
=
request
.
get
(
field_id
)
value
=
request
.
get
(
field_id
)
if
callable
(
value
):
if
callable
(
value
):
...
@@ -55,17 +55,17 @@ def editListBox(listbox_field, listbox):
...
@@ -55,17 +55,17 @@ def editListBox(listbox_field, listbox):
""" Function called to edit a listbox
""" Function called to edit a listbox
"""
"""
if
listbox
is
not
None
:
if
listbox
is
not
None
:
g
v
=
{}
g
lobal_property_dict
=
{}
if
listbox_field
.
has_value
(
'global_attributes'
):
if
listbox_field
.
has_value
(
'global_attributes'
):
hidden_attribute
s
=
map
(
lambda
x
:
x
[
0
],
listbox_field
.
get_value
(
'global_attributes'
))
hidden_attribute
_list
=
map
(
lambda
x
:
x
[
0
],
listbox_field
.
get_value
(
'global_attributes'
))
for
k
in
hidden_attributes
:
for
hidden_attribute
in
hidden_attribute_list
:
g
v
[
k
]
=
getattr
(
request
,
k
,
None
)
g
lobal_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
for
url
,
v
in
listbox
.
items
():
for
item_url
,
listbox_item_dict
in
listbox
.
items
():
v
.
update
(
gv
)
listbox_item_dict
.
update
(
global_property_dict
)
# Form: '' -> ERP5: None
# Form: '' -> ERP5: None
encapsulated_editor_list
=
[]
encapsulated_editor_list
=
[]
cleaned_v
=
{}
cleaned_v
=
{}
for
key
,
value
in
v
.
items
():
for
key
,
value
in
listbox_item_dict
.
items
():
if
hasattr
(
value
,
'edit'
):
if
hasattr
(
value
,
'edit'
):
encapsulated_editor_list
.
append
(
value
)
encapsulated_editor_list
.
append
(
value
)
else
:
else
:
...
@@ -75,10 +75,10 @@ def editListBox(listbox_field, listbox):
...
@@ -75,10 +75,10 @@ def editListBox(listbox_field, listbox):
if
cleaned_v
:
if
cleaned_v
:
if
listbox_edit
is
None
:
if
listbox_edit
is
None
:
obj
=
context
.
restrictedTraverse
(
url
)
obj
=
context
.
restrictedTraverse
(
item_
url
)
obj
.
edit
(
edit_order
=
edit_order
,
**
cleaned_v
)
obj
.
edit
(
edit_order
=
edit_order
,
**
cleaned_v
)
else
:
else
:
listbox_edit
(
url
,
edit_order
,
cleaned_v
)
listbox_edit
(
item_
url
,
edit_order
,
cleaned_v
)
for
encapsulated_editor
in
encapsulated_editor_list
:
for
encapsulated_editor
in
encapsulated_editor_list
:
encapsulated_editor
.
edit
(
obj
)
encapsulated_editor
.
edit
(
obj
)
...
@@ -95,14 +95,14 @@ def editMatrixBox(matrixbox_field, matrixbox):
...
@@ -95,14 +95,14 @@ def editMatrixBox(matrixbox_field, matrixbox):
else
:
else
:
matrix_context
=
context
matrix_context
=
context
if
matrix_context
is
not
None
:
if
matrix_context
is
not
None
:
k
d
=
{}
k
_dict
=
{}
k
d
[
'portal_type'
]
=
portal_type
k
_dict
[
'portal_type'
]
=
portal_type
k
d
[
'base_id'
]
=
cell_base_id
k
_dict
[
'base_id'
]
=
cell_base_id
g
v
=
{}
g
lobal_property_dict
=
{}
if
matrixbox_field
.
has_value
(
'global_attributes'
):
if
matrixbox_field
.
has_value
(
'global_attributes'
):
hidden_attribute
s
=
[
x
[
0
]
for
x
in
matrixbox_field
.
get_value
(
'global_attributes'
)]
hidden_attribute
_list
=
[
x
[
0
]
for
x
in
matrixbox_field
.
get_value
(
'global_attributes'
)]
for
k
in
hidden_attributes
:
for
hidden_attribute
in
hidden_attribute_list
:
g
v
[
k
]
=
getattr
(
request
,
k
,
None
)
g
lobal_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
if
matrixbox_field
.
get_value
(
'update_cell_range'
):
if
matrixbox_field
.
get_value
(
'update_cell_range'
):
as_cell_range_script_id
=
matrixbox_field
.
get_value
(
as_cell_range_script_id
=
matrixbox_field
.
get_value
(
'as_cell_range_script_id'
)
'as_cell_range_script_id'
)
...
@@ -157,57 +157,57 @@ def editMatrixBox(matrixbox_field, matrixbox):
...
@@ -157,57 +157,57 @@ def editMatrixBox(matrixbox_field, matrixbox):
if
cell_range
!=
matrixbox_cell_range
:
if
cell_range
!=
matrixbox_cell_range
:
matrix_context
.
setCellRange
(
base_id
=
cell_base_id
,
*
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
# Only update cells which still exist
if
matrix_context
.
hasInRange
(
*
k
,
**
kd
):
if
matrix_context
.
hasInRange
(
*
cell_index_tuple
,
**
k_dict
):
c
=
matrix_context
.
newCell
(
*
k
,
**
kd
)
c
ell
=
matrix_context
.
newCell
(
*
cell_index_tuple
,
**
k_dict
)
if
c
is
not
None
:
if
c
ell
is
not
None
:
c
.
edit
(
edit_order
=
edit_order
,
**
gv
)
# First update globals which include the def. of property_list
c
ell
.
edit
(
edit_order
=
edit_order
,
**
global_property_dict
)
# First update globals which include the def. of property_list
if
v
.
has_key
(
'variated_property'
):
if
cell_dict
.
has_key
(
'variated_property'
):
# For Variated Properties
# For Variated Properties
va
lue
=
v
[
'variated_property'
]
va
riated_property
=
cell_dict
[
'variated_property'
]
del
v
[
'variated_property'
]
del
cell_dict
[
'variated_property'
]
if
g
v
.
has_key
(
'mapped_value_property_list'
):
if
g
lobal_property_dict
.
has_key
(
'mapped_value_property_list'
):
# Change the property which is defined by the
# Change the property which is defined by the
# first element of mapped_value_property_list
# first element of mapped_value_property_list
# XXX May require some changes with Sets
# XXX May require some changes with Sets
key
=
g
v
[
'mapped_value_property_list'
][
0
]
key
=
g
lobal_property_dict
[
'mapped_value_property_list'
][
0
]
v
[
key
]
=
value
cell_dict
[
key
]
=
variated_property
# Form: '' -> ERP5: None
# Form: '' -> ERP5: None
cleaned_v
=
v
.
copy
()
cleaned_v
=
cell_dict
.
copy
()
for
key
,
value
in
cleaned_v
.
items
():
for
key
,
value
in
cleaned_v
.
items
():
if
value
==
''
:
if
value
==
''
:
cleaned_v
[
key
]
=
None
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
:
else
:
return
"Could not create cell %s"
%
str
(
k
)
return
"Could not create cell %s"
%
str
(
cell_index_tuple
)
else
:
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
)
field_prefix_len
=
len
(
field_prefix
)
def
parseField
(
f
):
def
parseField
(
f
ield
):
"""
"""
Parse given form field, to put them in
Parse given form field, to put them in
kw or in encapsulated_editor_list
kw or in encapsulated_editor_list
"""
"""
k
=
f
.
id
field_id
=
field
.
id
if
f
.
has_value
(
'alternate_name'
):
if
f
ield
.
has_value
(
'alternate_name'
):
k
=
f
.
get_value
(
'alternate_name'
)
or
f
.
id
field_id
=
field
.
get_value
(
'alternate_name'
)
or
field_
id
v
=
getattr
(
request
,
k
,
MARKER
)
v
alue
=
getattr
(
request
,
field_id
,
MARKER
)
if
hasattr
(
v
,
'edit'
):
if
hasattr
(
v
alue
,
'edit'
):
# This is an encapsulated editor
# This is an encapsulated editor
# call it
# call it
encapsulated_editor_list
.
append
(
v
)
encapsulated_editor_list
.
append
(
v
alue
)
elif
v
is
not
MARKER
:
elif
v
alue
is
not
MARKER
:
if
k
.
startswith
(
field_prefix
):
if
field_id
.
startswith
(
field_prefix
):
# We only take into account
# We only take into account
# the object attributes
# the object attributes
k
=
k
[
field_prefix_len
:]
field_id
=
field_id
[
field_prefix_len
:]
# Form: '' -> ERP5: None
# Form: '' -> ERP5: None
if
v
==
''
:
if
v
alue
==
''
:
v
=
None
v
alue
=
None
kw
[
k
]
=
v
kw
[
field_id
]
=
value
# Some initilizations
# Some initilizations
kw
=
{}
kw
=
{}
...
@@ -246,12 +246,12 @@ if message_only:
...
@@ -246,12 +246,12 @@ if message_only:
ignore_layout
=
int
(
ignore_layout
)
ignore_layout
=
int
(
ignore_layout
)
editable_mode
=
int
(
editable_mode
)
editable_mode
=
int
(
editable_mode
)
s
pp
=
context
.
getPhysicalPath
()
s
erver_physical_path
=
context
.
getPhysicalPath
()
s
pp
=
list
(
spp
)
s
erver_physical_path
=
list
(
server_physical_path
)
s_url
=
request
[
"SERVER_URL"
]
s
erver
_url
=
request
[
"SERVER_URL"
]
s
pp
.
insert
(
0
,
s
_url
)
s
erver_physical_path
.
insert
(
0
,
server
_url
)
#calculate direct the url instead of using absolute_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
# for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'.
# after 'Save & View'.
...
...
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