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
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
Mukul
erp5
Commits
93aa3c0b
Commit
93aa3c0b
authored
Jan 12, 2018
by
Tomáš Peterka
Committed by
Tomáš Peterka
Jan 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Cleanup callDialogMethod
parent
ba7f44cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
40 deletions
+33
-40
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
...portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
+33
-40
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
View file @
93aa3c0b
...
@@ -6,26 +6,25 @@ from Products.ERP5Type.Log import log, DEBUG, INFO, WARNING
...
@@ -6,26 +6,25 @@ from Products.ERP5Type.Log import log, DEBUG, INFO, WARNING
# XXX We should not use meta_type properly,
# XXX We should not use meta_type properly,
# XXX We need to discuss this problem.(yusei)
# XXX We need to discuss this problem.(yusei)
def
isListBox
(
field
):
def
isFieldType
(
field
,
type_name
):
if
field
.
meta_type
==
'ListBox'
:
if
field
.
meta_type
==
'ProxyField'
:
return
True
field
=
field
.
getRecursiveTemplateField
()
elif
field
.
meta_type
==
'ProxyField'
:
return
field
.
meta_type
==
type_name
template_field
=
field
.
getRecursiveTemplateField
()
if
template_field
.
meta_type
==
'ListBox'
:
from
Products.Formulator.Errors
import
FormValidationError
,
ValidationError
return
True
return
False
from
Products.Formulator.Errors
import
FormValidationError
from
ZTUtils
import
make_query
from
ZTUtils
import
make_query
request
=
REQUEST
request
=
REQUEST
if
REQUEST
is
None
:
if
REQUEST
is
None
:
request
=
container
.
REQUEST
request
=
container
.
REQUEST
# request.form holds POST data thus containing 'field_' + field.id items
# such as 'field_your_some_field'
request_form
=
request
.
form
request_form
=
request
.
form
error_message
=
''
error_message
=
''
translate
=
context
.
Base_translateString
# Make this script work alike
wether called from another script or by
a request
# Make this script work alike
no matter if called by a script or
a request
kw
.
update
(
request_form
)
kw
.
update
(
request_form
)
# Exceptions for UI
# Exceptions for UI
...
@@ -63,6 +62,7 @@ if dialog_method == 'Base_editRelation':
...
@@ -63,6 +62,7 @@ if dialog_method == 'Base_editRelation':
listbox_uid
=
kw
.
get
(
'listbox_uid'
,
None
),
listbox_uid
=
kw
.
get
(
'listbox_uid'
,
None
),
saved_form_data
=
kw
[
'saved_form_data'
])
saved_form_data
=
kw
[
'saved_form_data'
])
# Exception for create relation
# Exception for create relation
# Not used in new UI - relation field implemented using JIO calls from JS
if
dialog_method
==
'Base_createRelation'
:
if
dialog_method
==
'Base_createRelation'
:
return
context
.
Base_createRelation
(
form_id
=
kw
[
'form_id'
],
return
context
.
Base_createRelation
(
form_id
=
kw
[
'form_id'
],
selection_name
=
kw
[
'list_selection_name'
],
selection_name
=
kw
[
'list_selection_name'
],
...
@@ -119,30 +119,27 @@ MARKER = [] # A recognisable default value. Use with 'is', not '=='.
...
@@ -119,30 +119,27 @@ MARKER = [] # A recognisable default value. Use with 'is', not '=='.
listbox_id_list
=
[]
# There should not be more than one listbox - but this give us a way to check.
listbox_id_list
=
[]
# There should not be more than one listbox - but this give us a way to check.
file_id_list
=
[]
# For uploaded files.
file_id_list
=
[]
# For uploaded files.
for
field
in
form
.
get_fields
():
for
field
in
form
.
get_fields
():
k
=
field
.
id
field_id
=
field
.
id
v
=
request
.
get
(
k
,
MARKER
)
field_value
=
request
.
get
(
field_id
,
MARKER
)
if
v
is
not
MARKER
:
if
isListBox
(
field
):
if
field_value
is
not
MARKER
:
listbox_id_list
.
append
(
k
)
if
isFieldType
(
field
,
"ListBox"
):
elif
can_redirect
and
(
v
in
(
None
,
[],
())
or
hasattr
(
v
,
'read'
))
:
# If we cannot redirect, useless to test it again
listbox_id_list
.
append
(
field_id
)
can_redirect
=
0
# Cleanup my_ and your_ prefixes if present
# Cleanup my_ and your_ prefixes
if
field_id
.
startswith
(
"my_"
)
or
field_id
.
startswith
(
"your_"
):
splitted
=
k
.
split
(
'_'
,
1
)
_
,
field_name
=
field_id
.
split
(
'_'
,
1
)
if
len
(
splitted
)
==
2
and
splitted
[
0
]
in
(
'my'
,
'your'
):
if
hasattr
(
field_value
,
'as_dict'
):
if
hasattr
(
v
,
'as_dict'
):
# This is an encapsulated editor - convert it
# This is an encapsulated editor
kw
.
update
(
field_value
.
as_dict
())
# convert it
kw
.
update
(
v
.
as_dict
())
else
:
else
:
kw
[
splitted
[
1
]]
=
request_form
[
splitted
[
1
]]
=
v
kw
[
field_name
]
=
request_form
[
field_name
]
=
field_value
else
:
else
:
kw
[
k
]
=
request_form
[
k
]
=
v
kw
[
field_id
]
=
request_form
[
field_id
]
=
field_value
if
len
(
listbox_id_list
):
if
len
(
listbox_id_list
):
can_redirect
=
0
# Warn if there are more than one listbox in form ...
# Warn if there are more than one listbox in form ...
if
len
(
listbox_id_list
)
>
1
:
if
len
(
listbox_id_list
)
>
1
:
log
(
'Base_callDialogMethod'
,
'There are %s listboxes in form %s.'
%
(
len
(
listbox_id_list
),
form
.
id
))
log
(
'Base_callDialogMethod'
,
'There are %s listboxes in form %s.'
%
(
len
(
listbox_id_list
),
form
.
id
))
...
@@ -183,11 +180,8 @@ if listbox_uid is not None and kw.has_key('list_selection_name'):
...
@@ -183,11 +180,8 @@ if listbox_uid is not None and kw.has_key('list_selection_name'):
selected_uids
=
context
.
portal_selections
.
updateSelectionCheckedUidList
(
selected_uids
=
context
.
portal_selections
.
updateSelectionCheckedUidList
(
kw
[
'list_selection_name'
],
kw
[
'list_selection_name'
],
listbox_uid
,
uids
)
listbox_uid
,
uids
)
# Remove unused parameter
# Remove empty values for make_query.
clean_kw
=
{}
clean_kw
=
dict
((
k
,
v
)
for
k
,
v
in
kw
.
items
()
if
v
not
in
(
None
,
[],
()))
for
k
,
v
in
kw
.
items
()
:
if
v
not
in
(
None
,
[],
())
:
clean_kw
[
k
]
=
kw
[
k
]
# Handle deferred style, unless we are executing the update action
# Handle deferred style, unless we are executing the update action
if
dialog_method
!=
update_method
and
clean_kw
.
get
(
'deferred_style'
,
0
):
if
dialog_method
!=
update_method
and
clean_kw
.
get
(
'deferred_style'
,
0
):
...
@@ -205,14 +199,13 @@ if dialog_method != update_method and clean_kw.get('deferred_style', 0):
...
@@ -205,14 +199,13 @@ if dialog_method != update_method and clean_kw.get('deferred_style', 0):
request
.
set
(
'deferred_style_dialog_method'
,
dialog_method
)
request
.
set
(
'deferred_style_dialog_method'
,
dialog_method
)
dialog_method
=
'Base_activateSimpleView'
dialog_method
=
'Base_activateSimpleView'
url_params_string
=
make_query
(
clean_kw
)
url_params_string
=
make_query
(
clean_kw
)
#
XXX: We always redirect in report mode to make sure portal_skin
#
Never redirect in JSON style - do as much as possible here.
#
parameter is taken into account by SkinTool.
#
At this point the 'dialog_method' should point to a form (if we are in report)
#
If url is too long, we do not redirect to avoid crash.
#
if we are not in Deferred mode - then it points to `Base_activateSimpleView`
# XXX: 2000 is an arbitrary value resulted from trial and error.
if
(
not
(
can_redirect
)
or
len
(
url_params_string
)
>
2000
)
:
if
True
:
if
dialog_method
!=
update_method
:
if
dialog_method
!=
update_method
:
# When we are not executing the update action, we have to change the skin
# When we are not executing the update action, we have to change the skin
# manually,
# manually,
...
...
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