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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
d42e8520
Commit
d42e8520
authored
Oct 15, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Jan 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: make erp5_hal_json_style compatible with Python 3.
parent
29d6c7b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
96 deletions
+107
-96
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
...portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
+3
-2
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_renderMessage.py
...em/portal_skins/erp5_hal_json_style/Base_renderMessage.py
+2
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+35
-33
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.py
...portal_skins/erp5_hal_json_style/Workflow_statusModify.py
+2
-1
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+65
-59
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
View file @
d42e8520
...
...
@@ -15,16 +15,17 @@ There are runtime values hidden in every dialog form (injected by getHateoas Scr
from
erp5.component.module.Log
import
log
,
WARNING
from
Products.Formulator.Errors
import
FormValidationError
import
json
import
six
# http://stackoverflow.com/a/13105359
def
byteify
(
value
):
if
isinstance
(
value
,
dict
):
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
value
.
iteritems
(
)}
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
six
.
iteritems
(
value
)}
elif
isinstance
(
value
,
list
):
return
[
byteify
(
element
)
for
element
in
value
]
elif
isinstance
(
value
,
tuple
):
return
tuple
(
byteify
(
element
)
for
element
in
value
)
elif
isinstance
(
value
,
unicod
e
):
elif
six
.
PY2
and
isinstance
(
value
,
six
.
text_typ
e
):
return
value
.
encode
(
'utf-8'
)
else
:
return
value
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_renderMessage.py
View file @
d42e8520
...
...
@@ -6,8 +6,9 @@ Return JSON with message to be displayed and set according HTTP STATUS for messa
"""
import
json
from
erp5.component.module.Log
import
WARNING
,
ERROR
import
six
if
isinstance
(
level
,
(
str
,
unicod
e
)):
if
isinstance
(
level
,
(
str
,
six
.
text_typ
e
)):
if
level
.
lower
()
==
"error"
:
response_code
=
500
elif
level
.
lower
().
startswith
(
"warn"
):
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
d42e8520
...
...
@@ -49,7 +49,7 @@ When handling form, we can expect field values to be stored in REQUEST.form in t
from
ZTUtils
import
make_query
import
json
import
urllib
from
six.moves.urllib.parse
import
urlencode
from
base64
import
urlsafe_b64encode
,
urlsafe_b64decode
from
DateTime
import
DateTime
from
ZODB.POSException
import
ConflictError
...
...
@@ -63,6 +63,7 @@ from Products.ERP5Type.Message import Message
from
collections
import
OrderedDict
from
Products.ERP5Form.Selection
import
Selection
from
Products.PythonScripts.standard
import
Object
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
import
six
...
...
@@ -84,7 +85,7 @@ def toBasicTypes(obj):
"""Ensure that obj contains only basic types."""
if
obj
is
None
:
return
obj
if
isinstance
(
obj
,
(
bool
,
float
,
str
)
+
six
.
integer_types
+
(
six
.
text_type
,)):
if
isinstance
(
obj
,
(
bool
,
float
,
str
)
+
six
.
integer_types
+
(
six
.
text_type
,
)):
return
obj
if
isinstance
(
obj
,
list
):
return
[
toBasicTypes
(
x
)
for
x
in
obj
]
...
...
@@ -125,12 +126,12 @@ def renderHiddenField(form, name, value):
# http://stackoverflow.com/a/13105359
def
byteify
(
string
):
if
isinstance
(
string
,
dict
):
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
s
tring
.
iteritems
(
)}
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
s
ix
.
iteritems
(
string
)}
elif
isinstance
(
string
,
list
):
return
[
byteify
(
element
)
for
element
in
string
]
elif
isinstance
(
string
,
tuple
):
return
tuple
(
byteify
(
element
)
for
element
in
string
)
elif
isinstance
(
string
,
unicod
e
):
elif
six
.
PY2
and
isinstance
(
string
,
six
.
text_typ
e
):
return
string
.
encode
(
'utf-8'
)
else
:
return
string
...
...
@@ -140,10 +141,11 @@ def ensureUTF8(obj):
"""Make sure string is UTF-8, by replacing characters that
cannot be decoded.
"""
if
isinstance
(
obj
,
str
):
return
obj
.
decode
(
'utf-8'
,
'replace'
).
encode
(
'utf-8'
)
elif
isinstance
(
obj
,
unicode
):
return
obj
.
encode
(
'utf-8'
,
'replace'
)
if
six
.
PY2
:
if
isinstance
(
obj
,
str
):
return
obj
.
decode
(
'utf-8'
,
'replace'
).
encode
(
'utf-8'
)
elif
isinstance
(
obj
,
six
.
text_type
):
return
obj
.
encode
(
'utf-8'
,
'replace'
)
return
obj
def
ensureSerializable
(
obj
):
...
...
@@ -422,8 +424,8 @@ def getFieldDefault(form, field, key, value=MARKER):
if value is MARKER:
# use marker because default value can be intentionally empty string
value = field.get_value('default', request=REQUEST, REQUEST=REQUEST)
if
field.has_value("unicode") and field.get_value("unicode") and isinstance(value, unicod
e):
value =
unicode(value,
form.get_form_encoding())
if
six.PY2 and field.has_value("unicode") and field.get_value("unicode") and isinstance(value, six.text_typ
e):
value =
value.decode(
form.get_form_encoding())
if getattr(value, 'translate', None) is not None:
return "%s" % value
return value
...
...
@@ -477,7 +479,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
selected_language
=
erp5_ui
.
get_selected_language
()
result
[
"translate_title_href"
]
=
'%s/manage_messages?%s'
%
(
'/'
.
join
(
erp5_ui
.
getPhysicalPath
()[
2
:]),
url
lib
.
url
encode
({
"regex"
:
"^%s$"
%
field
.
title
(),
urlencode
({
"regex"
:
"^%s$"
%
field
.
title
(),
"lang"
:
selected_language
})
)
...
...
@@ -485,7 +487,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
if
field_description
:
result
[
"translate_description_href"
]
=
'%s/manage_messages?%s'
%
(
'/'
.
join
(
erp5_ui
.
getPhysicalPath
()[
2
:]),
url
lib
.
url
encode
({
"regex"
:
"^%s$"
%
field_description
,
urlencode
({
"regex"
:
"^%s$"
%
field_description
,
"lang"
:
selected_language
})
)
...
...
@@ -667,11 +669,11 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"script_id"
:
script
.
id
,
"relative_url"
:
getRealRelativeUrl
(
traversed_document
).
replace
(
"/"
,
"%2F"
),
"view"
:
"Base_viewRelatedObjectList"
,
"extra_param_json"
:
urlsafe_b64encode
(
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
({
'original_form_id'
:
form
.
id
,
'field_id'
:
field
.
id
})))
})))
))
}
})
...
...
@@ -720,7 +722,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
or
field
.
get_value
(
"editable_columns"
))]
all_column_list
=
[(
name
,
title
)
for
name
,
title
in
field
.
get_value
(
"all_columns"
)]
catalog_column_list
=
[(
name
,
title
)
for
name
,
title
in
OrderedDict
(
column_list
+
all_column_list
).
items
(
)
for
name
,
title
in
six
.
iteritems
(
OrderedDict
(
column_list
+
all_column_list
)
)
if
sql_catalog
.
isValidColumn
(
name
)]
# try to get specified searchable columns and fail back to all searchable columns
...
...
@@ -792,10 +794,10 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"relative_url"
:
getRealRelativeUrl
(
traversed_document
).
replace
(
"/"
,
"%2F"
),
"form_relative_url"
:
"%s/%s"
%
(
form_relative_url
,
field
.
id
),
"list_method"
:
list_method_name
,
"default_param_json"
:
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
(
list_method_query_dict
))),
"extra_param_json"
:
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
(
extra_param_dict
)))
"default_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
(
list_method_query_dict
)))
))
,
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
(
extra_param_dict
)))
))
}
# once we imprint `default_params` into query string of 'list method' we
# don't want them to propagate to the query as well
...
...
@@ -814,7 +816,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"script_id": script.id,
"relative_url": traversed_document.getRelativeUrl().replace("/", "%2F"),
"list_method": list_method_name,
"default_param_json":
urlsafe_b64encode(json.dumps(ensureSerializable(list_method_query_dict
)))
"default_param_json":
bytes2str(urlsafe_b64encode(str2bytes(json.dumps(ensureSerializable(list_method_query_dict))
)))
}
list_method_query_dict = {}
"""
...
...
@@ -1058,12 +1060,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
"script_id"
:
script
.
id
,
"relative_url"
:
getRealRelativeUrl
(
traversed_document
).
replace
(
"/"
,
"%2F"
),
"view"
:
"Base_viewRelatedObjectList"
,
"extra_param_json"
:
urlsafe_b64encode
(
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
({
'proxy_listbox_id'
:
x
,
'original_form_id'
:
extra_param_json
[
'original_form_id'
],
'field_id'
:
extra_param_json
[
'field_id'
]
})))
})))
))
})
for
x
,
y
in
proxy_form_id_list
],
"first_item"
:
1
,
"required"
:
0
,
...
...
@@ -1081,12 +1083,12 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
"script_id"
:
script
.
id
,
"relative_url"
:
getRealRelativeUrl
(
traversed_document
).
replace
(
"/"
,
"%2F"
),
"view"
:
"Base_viewRelatedObjectList"
,
"extra_param_json"
:
urlsafe_b64encode
(
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
({
'proxy_listbox_id'
:
REQUEST
.
get
(
'proxy_listbox_id'
,
None
),
'original_form_id'
:
extra_param_json
[
'original_form_id'
],
'field_id'
:
extra_param_json
[
'field_id'
]
})))
})))
))
}
# Go through all groups ("left", "bottom", "hidden" etc.) and add fields from
...
...
@@ -1284,7 +1286,7 @@ def renderFormDefinition(form, response_dict):
def
statusLevelToString
(
level
):
"""Transform any level format to lowercase string representation"""
if
isinstance
(
level
,
(
str
,
unicod
e
)):
if
isinstance
(
level
,
(
str
,
six
.
text_typ
e
)):
if
level
.
lower
()
==
"error"
:
return
"error"
elif
level
.
lower
().
startswith
(
"warn"
):
...
...
@@ -1585,7 +1587,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"script_id"
:
script
.
id
,
# this script (ERP5Document_getHateoas)
"relative_url"
:
getRealRelativeUrl
(
traversed_document
).
replace
(
"/"
,
"%2F"
),
"view"
:
erp5_action_list
[
-
1
][
'name'
],
"extra_param_json"
:
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
(
extra_param_json
)))
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
(
extra_param_json
))
)))
}
if
erp5_action_list
:
...
...
@@ -1739,7 +1741,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# Those parameter will be send back during the listbox submission
# to ensure fetching the same lines
listbox_query_param_json
=
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
({
listbox_query_param_json
=
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
({
'form_relative_url'
:
form_relative_url
,
'list_method'
:
list_method
,
'default_param_json'
:
default_param_json
,
...
...
@@ -1752,7 +1754,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'relative_url'
:
relative_url
,
'group_by'
:
group_by
,
'sort_on'
:
sort_on
})))
})))
))
# set 'here' for field rendering which contain TALES expressions
REQUEST
.
set
(
'here'
,
traversed_document
)
...
...
@@ -1926,7 +1928,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
column_list = [(name, title) for name, title in source_field.get_value("
columns
") if name in select_list]
all_column_list = [(name, title) for name, title in source_field.get_value("
all_columns
") if name in select_list]
selection_kw['columns'] = [(name, title)
for name, title in
OrderedDict(column_list + all_column_list).items(
)]
for name, title in
six.iteritems(OrderedDict(column_list + all_column_list)
)]
else:
selection_kw['columns'] = []
...
...
@@ -2198,8 +2200,8 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"script_id"
:
script
.
id
,
"relative_url"
:
url_parameter_dict
[
'view_kw'
][
'jio_key'
].
replace
(
"/"
,
"%2F"
),
"view"
:
url_parameter_dict
[
'view_kw'
][
'view'
],
"extra_param_json"
:
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
(
extra_url_param_dict
)))
"extra_param_json"
:
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
(
extra_url_param_dict
)))
))
}
# endfor select
...
...
@@ -2416,8 +2418,8 @@ if mode == 'url_generator':
keep_items_json
=
None
else
:
generator_key
=
'traverse_generator_action'
keep_items_json
=
urlsafe_b64encode
(
json
.
dumps
(
ensureSerializable
(
keep_items
)))
keep_items_json
=
bytes2str
(
urlsafe_b64encode
(
str2bytes
(
json
.
dumps
(
ensureSerializable
(
keep_items
)))
))
return
url_template_dict
[
generator_key
]
%
{
"root_url"
:
site_root
.
absolute_url
(),
"script_id"
:
'ERP5Document_getHateoas'
,
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.py
View file @
d42e8520
...
...
@@ -3,6 +3,7 @@ from Products.Formulator.Errors import FormValidationError
from
Products.ERP5Type.Core.Workflow
import
ValidationFailed
from
Products.ERP5Type.Message
import
translateString
from
erp5.component.module.Log
import
WARNING
import
six
portal
=
context
.
getPortalObject
()
request
=
REQUEST
or
context
.
REQUEST
...
...
@@ -43,7 +44,7 @@ for f in form.get_fields():
listbox
=
request
.
get
(
'listbox'
)
# XXX: hardcoded field name
if
listbox
is
not
None
:
listbox_line_list
=
[]
for
key
,
value
in
sorted
(
listbox
.
iteritems
(
)):
for
key
,
value
in
sorted
(
six
.
iteritems
(
listbox
)):
value
[
'listbox_key'
]
=
key
listbox_line_list
.
append
(
value
)
doaction_param_list
[
'listbox'
]
=
tuple
(
listbox_line_list
)
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
d42e8520
...
...
@@ -15,12 +15,13 @@ import DateTime
import
StringIO
import
json
import
re
import
urllib
from
six.moves.urllib.parse
import
quote
,
quote_plus
import
mock
from
zope.globalrequest
import
setRequest
# pylint: disable=no-name-in-module, import-error
from
Acquisition
import
aq_base
from
Products.ERP5Form.Selection
import
Selection
,
DomainSelection
from
Products.ERP5Type.Utils
import
ensure_list
,
str2unicode
,
unicode2str
def
changeSkin
(
skin_name
):
...
...
@@ -123,7 +124,7 @@ def do_fake_request(request_method, headers=None, data=()):
if
data
and
request_method
.
upper
()
==
'GET'
:
# see: GET http://www.cgi101.com/book/ch3/text.html
env
[
'QUERY_STRING'
]
=
'&'
.
join
(
'{}={}'
.
format
(
urllib
.
quote_plus
(
key
),
urllib
.
quote
(
value
))
'{}={}'
.
format
(
quote_plus
(
key
),
quote
(
value
))
for
key
,
value
in
data
)
...
...
@@ -132,7 +133,7 @@ def do_fake_request(request_method, headers=None, data=()):
env
[
'CONTENT_TYPE'
]
=
'application/x-www-form-urlencoded'
for
key
,
value
in
data
:
body_stream
.
write
(
'{}={!s}&'
.
format
(
urllib
.
quote_plus
(
key
),
urllib
.
quote
(
value
)))
quote_plus
(
key
),
quote
(
value
)))
request
=
HTTPRequest
(
body_stream
,
env
,
HTTPResponse
())
if
data
and
request_method
.
upper
()
==
'POST'
:
...
...
@@ -346,21 +347,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Custom Action No Dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'name'
],
"custom_action_no_dialog"
)
...
...
@@ -374,17 +375,17 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'name'
],
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_debug'
],
"root"
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
...
...
@@ -413,21 +414,21 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=embed_action"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Embed"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'name'
],
"embed_action"
)
...
...
@@ -440,7 +441,7 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
...
...
@@ -457,10 +458,10 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'traverse'
][
'templated'
],
True
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'traverse'
][
'name'
],
"Traverse"
)
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'default_view'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_debug'
],
"root"
)
...
...
@@ -502,21 +503,21 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Custom Action No Dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'name'
],
"custom_action_no_dialog"
)
...
...
@@ -529,17 +530,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'name'
],
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_debug'
],
"traverse"
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
...
...
@@ -595,28 +596,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Custom Action No Dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'name'
],
"custom_action_no_dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'title'
],
"Queries"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'name'
],
"jump_query"
)
...
...
@@ -629,17 +630,17 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'name'
],
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_debug'
],
"traverse"
)
# Check embedded form rendering
...
...
@@ -683,7 +684,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'self'
][
'href'
],
"%s/%s/Foo_view"
%
(
self
.
portal
.
absolute_url
(),
...
...
@@ -895,11 +896,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_debug'
],
"traverse"
)
# Check embedded form rendering
...
...
@@ -920,7 +921,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'self'
][
'href'
],
"%s/%s/Foo_view"
%
(
self
.
portal
.
absolute_url
(),
...
...
@@ -968,28 +969,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Custom Action No Dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_workflow'
][
0
][
'name'
],
"custom_action_no_dialog"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'title'
],
"Queries"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_jio_jump'
][
'name'
],
"jump_query"
)
...
...
@@ -1002,14 +1003,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkJhc2Vfdmlld01ldGFkYXRhIn0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'name'
],
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_debug'
],
"traverse"
)
# Check embedded form rendering
...
...
@@ -1030,7 +1031,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_links'
][
'self'
][
'href'
],
"%s/Base_viewMetadata"
%
document
.
getRelativeUrl
())
...
...
@@ -1198,7 +1199,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
traversed_document
']['
href
'], '
urn
:
jio
:
get
:
%
s
' % document.getRelativeUrl())
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
traversed_document
']['
name
'], document.getRelativeUrl())
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
traversed_document
']['
title
'],
document.getTitle().decode("UTF-8"
))
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
traversed_document
']['
title
'],
str2unicode(document.getTitle()
))
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
form_definition
']['
href
'], '
urn
:
jio
:
get
:
portal_skins
/
erp5_core
/
Base_viewWorkflowHistory
')
self.assertEqual(result_dict['
_embedded
']['
_view
']['
report_section_list
'][1]['
_links
']['
form_definition
']['
name
'], '
Base_viewWorkflowHistory
')
...
...
@@ -1252,14 +1253,14 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
# self.assertEqual(result_dict['
_links
']['
view
'][0]['
href
'],
# "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % (
# self.portal.absolute_url(),
#
urllib.
quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# self.assertEqual(result_dict['
_links
']['
view
'][0]['
title
'], "Consistency")
# self.assertEqual(result_dict['
_links
']['
view
'][0]['
name
'], "consistency")
# self.assertEqual(result_dict['
_links
']['
action_object_view
'][0]['
href
'],
# "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=consistency" % (
# self.portal.absolute_url(),
#
urllib.
quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# quote_plus("portal_skins/erp5_ui_test/Foo_view")))
# self.assertEqual(result_dict['
_links
']['
action_object_view
'][0]['
title
'], "Consistency")
# self.assertEqual(result_dict['
_links
']['
action_object_view
'][0]['
name
'], "consistency")
...
...
@@ -1300,7 +1301,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
)
result_dict = json.loads(result)
self.assertEqual(
result_dict['
title
'].encode('
UTF
-
8
'
), document.getTitle())
self.assertEqual(
unicode2str(result_dict['
title
']
), document.getTitle())
self.assertEqual(
result_dict['
_embedded
']['
_view
']['
_embedded
']['
form_definition
']['
pt
'],
'
form_view
'
...
...
@@ -2068,7 +2069,7 @@ return url
# Test the URL value
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'url_value'
][
'command'
],
'raw'
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'url_value'
][
'options'
].
keys
(
),
[
u'url'
,
u'reset'
])
self
.
assertEqual
(
ensure_list
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'url_value'
][
'options'
].
keys
()
),
[
u'url'
,
u'reset'
])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'url_value'
][
'options'
][
'url'
],
'https://officejs.com'
)
# Test if the value of the column is with right key
...
...
@@ -2164,7 +2165,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
self
.
assertEqual
(
2
,
len
(
result_dict
[
'_embedded'
][
'contents'
]))
# Test the listbox_uid parameter
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'listbox_uid:list'
][
'key'
],
'listbox_uid:list'
)
self
.
assertEqual
(
document_list
[
0
].
getReference
(),
result_dict
[
'_embedded'
][
'contents'
][
0
][
'reference'
].
encode
(
'UTF-8'
))
self
.
assertEqual
(
document_list
[
0
].
getReference
(),
unicode2str
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'reference'
]
))
# There is a count method on the listbox
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'count'
],
0
)
...
...
@@ -2179,10 +2180,10 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
2
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
].
encode
(
'utf-8'
),
document_list
[
0
].
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
]
),
document_list
[
0
].
getTitle
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'Foo_getLocalTitle'
],
None
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'getTotalQuantity'
],
0
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
1
][
'title'
].
encode
(
'utf-8'
),
document_list
[
1
].
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'_embedded'
][
'contents'
][
1
][
'title'
]
),
document_list
[
1
].
getTitle
())
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
1
][
'Foo_getLocalTitle'
],
None
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
1
][
'getTotalQuantity'
],
0
)
# No count if not in the listbox context currently
...
...
@@ -2621,21 +2622,21 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_view'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view"
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_view'
][
0
][
'title'
],
"View"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_view'
][
0
][
'name'
],
"view"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_workflow'
][
0
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=custom_action_no_dialog&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_workflow'
][
0
][
'title'
],
"Custom Action No Dialog"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_workflow'
][
0
][
'name'
],
"custom_action_no_dialog"
)
...
...
@@ -2648,14 +2649,14 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_new_content_action'
][
'href'
],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=create_a_document&extra_param_json=eyJmb3JtX2lkIjogIkZvb192aWV3In0="
%
(
self
.
portal
.
absolute_url
(),
urllib
.
quote_plus
(
document
.
getRelativeUrl
())))
quote_plus
(
document
.
getRelativeUrl
())))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_new_content_action'
][
'title'
],
"Create a Document"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'action_object_new_content_action'
][
'name'
],
"create_a_document"
)
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_links'
][
'type'
][
'name'
],
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'result_list'
][
0
][
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_debug'
],
"traverse"
)
# Check embedded form rendering
...
...
@@ -2676,7 +2677,7 @@ class TestERP5Document_getHateoas_mode_bulk(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'href'
],
'urn:jio:get:%s'
%
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'name'
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
document
.
getTitle
().
decode
(
"UTF-8"
))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_embedded'
][
'_view'
][
'_links'
][
'traversed_document'
][
'title'
],
str2unicode
(
document
.
getTitle
()
))
self
.
assertEqual
(
result_dict
[
'result_list'
][
0
][
'_embedded'
][
'_view'
][
'_links'
][
'self'
][
'href'
],
"%s/%s/Foo_view"
%
(
self
.
portal
.
absolute_url
(),
...
...
@@ -2738,8 +2739,10 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin):
self
.
assertTrue
(
work_list
[
0
][
'count'
]
>
0
)
self
.
assertEqual
(
work_list
[
0
][
'name'
],
'Draft To Validate'
)
self
.
assertNotIn
(
'module'
,
work_list
[
0
])
self
.
assertEqual
(
work_list
[
0
][
'href'
],
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22'
)
self
.
assertIn
(
work_list
[
0
][
'href'
],
(
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22'
,
'urn:jio:allDocs?query=simulation_state%3A%22draft%22%20AND%20portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29'
,
))
self
.
assertEqual
(
result_dict
[
'_debug'
],
"worklist"
)
...
...
@@ -2847,7 +2850,7 @@ if translation_service is not None :\n\
if not encoding:
\
n
\
return translation_service.translate(catalog, msg, lang=lang, **kw)
\
n
\
msg = translation_service.translate(catalog, msg, lang=lang, **kw)
\
n
\
if same_type(msg, u''):
\
n
\
if s
tr==bytes and s
ame_type(msg, u''):
\
n
\
msg = msg.encode(encoding)
\
n
\
return msg
\
n
\
except AttributeError:
\
n
\
...
...
@@ -2911,7 +2914,7 @@ return msg"
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'href'
],
'urn:jio:get:portal_types/%s'
%
document
.
getPortalType
())
self
.
assertEqual
(
result_dict
[
'_links'
][
'type'
][
'name'
],
'Foo_zhongwen'
)
self
.
assertEqual
(
result_dict
[
'title'
].
encode
(
"UTF-8"
),
document
.
getTitle
())
self
.
assertEqual
(
unicode2str
(
result_dict
[
'title'
]
),
document
.
getTitle
())
self
.
assertEqual
(
result_dict
[
'_debug'
],
"root"
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
...
...
@@ -2939,7 +2942,10 @@ return msg"
self
.
assertEqual
(
work_list
[
0
][
'name'
],
'daiyanzhen'
)
self
.
assertEqual
(
work_list
[
0
][
'count'
],
1
)
self
.
assertNotIn
(
'module'
,
work_list
[
0
])
self
.
assertEqual
(
work_list
[
0
][
'href'
],
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22'
)
self
.
assertIn
(
work_list
[
0
][
'href'
],
(
'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22'
,
'urn:jio:allDocs?query=simulation_state%3A%22draft%22%20AND%20portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29'
,
))
self
.
assertEqual
(
result_dict
[
'_debug'
],
"worklist"
)
...
...
@@ -3008,7 +3014,7 @@ return msg"
result_dict
=
json
.
loads
(
result
)
# The document title includes 'ö' at the last in this test class, so calling decode("UTF-8")
self
.
assertEqual
(
result_dict
[
'_links'
][
'parent'
],
{
"href"
:
"urn:jio:get:%s"
%
document
.
getRelativeUrl
(),
"name"
:
document
.
getTitle
().
decode
(
"UTF-8"
)})
{
"href"
:
"urn:jio:get:%s"
%
document
.
getRelativeUrl
(),
"name"
:
str2unicode
(
document
.
getTitle
()
)})
# make sure traversing the child document does not adding the parent title translation
self
.
assertFalse
(
message_catalog
.
message_exists
(
document_title
))
...
...
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