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
alecs_myu
erp5
Commits
17f5aec9
Commit
17f5aec9
authored
Jul 11, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_ods_style] Allow to export module into a spreadsheet in ERP5JS
parent
80bb093d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
4 deletions
+166
-4
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+163
-2
bt5/erp5_hal_json_style/bt/test_dependency_list
bt5/erp5_hal_json_style/bt/test_dependency_list
+2
-1
bt5/erp5_ods_style/ActionTemplateItem/portal_types/portal_actions/ods_export.xml
...onTemplateItem/portal_types/portal_actions/ods_export.xml
+1
-1
No files found.
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
17f5aec9
...
...
@@ -16,6 +16,8 @@ import json
import
re
import
urllib
from
zope.globalrequest
import
setRequest
from
Acquisition
import
aq_base
from
Products.ERP5Form.Selection
import
Selection
,
DomainSelection
...
...
@@ -129,7 +131,29 @@ def do_fake_request(request_method, headers=None, data=()):
body_stream
.
write
(
'{}={!s}&'
.
format
(
urllib
.
quote_plus
(
key
),
urllib
.
quote
(
value
)))
return
HTTPRequest
(
body_stream
,
env
,
HTTPResponse
())
request
=
HTTPRequest
(
body_stream
,
env
,
HTTPResponse
())
if
data
and
request_method
.
upper
()
==
'POST'
:
for
key
,
value
in
data
:
request
.
form
[
key
]
=
value
return
request
def
replace_request
(
new_request
,
context
):
base_chain
=
[
aq_base
(
x
)
for
x
in
context
.
aq_chain
]
# Grab existig request (last chain item) and create a copy.
request_container
=
base_chain
.
pop
()
# request = request_container.REQUEST
setRequest
(
new_request
)
new_request_container
=
request_container
.
__class__
(
REQUEST
=
new_request
)
# Recreate acquisition chain.
my_self
=
new_request_container
base_chain
.
reverse
()
for
item
in
base_chain
:
my_self
=
item
.
__of__
(
my_self
)
return
my_self
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
...
@@ -2605,4 +2629,141 @@ class TestERP5Action_getHateoas(ERP5HALJSONStyleSkinsMixin):
'your_custom_workflow_variable'
,
response
))
self
.
assertIn
(
'error_text'
,
response
[
'your_custom_workflow_variable'
],
"Invalid field must contain error message"
)
self
.
assertGreater
(
len
(
response
[
'your_custom_workflow_variable'
][
'error_text'
]),
0
,
"Error message must not be empty"
)
\ No newline at end of file
class
TestERP5ODS
(
ERP5HALJSONStyleSkinsMixin
):
def
afterSetUp
(
self
):
ERP5HALJSONStyleSkinsMixin
.
afterSetUp
(
self
)
document
=
self
.
_makeDocument
()
document
.
edit
(
title
=
'foook1'
)
document
=
self
.
_makeDocument
()
document
.
edit
(
title
=
'foook2'
)
document
=
self
.
_makeDocument
()
document
.
edit
(
title
=
'foonotok'
)
self
.
tic
()
@
changeSkin
(
'Hal'
)
def
test_getHateoas_exportCSV
(
self
,
**
kw
):
"""Check that ODS export returns lines calculated from latest search
"""
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
ListBox_setPropertyList
(
field_columns
=
'
\
n
'
.
join
((
'id | ID'
,
'title | Title'
,
'creation_date | Creation Date'
,
)))
# Create the listbox selection
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"search"
,
# local_roles=["Manager"],
query
=
'title:"foook%"'
,
list_method
=
'searchFolder'
,
select_list
=
[
'title'
,
'creation_date'
,
'uid'
],
relative_url
=
'foo_module'
,
form_relative_url
=
'portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
,
sort_on
=
json
.
dumps
([
"title"
,
"descending"
])
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
2
)
# Export as CSV
fake_request
=
do_fake_request
(
"POST"
,
data
=
(
(
'dialog_method'
,
'Base_viewAsODS'
),
(
'dialog_id'
,
'Base_viewAsODSDialog'
),
(
'form_id'
,
'FooModule_viewFooList'
),
(
'selection_name'
,
'foo_selection'
),
(
'field_your_print_mode'
,
'list'
),
(
'default_field_your_print_mode:int'
,
'0'
),
(
'field_your_format'
,
'csv'
),
(
'default_field_your_format:int'
,
'0'
),
(
'field_your_target_language'
,
''
),
(
'default_field_your_target_language:int'
,
'0'
),
(
'extra_param_json'
,
'{}'
),
))
fake_portal
=
replace_request
(
fake_request
,
self
.
portal
)
result
=
fake_portal
.
web_site_module
.
hateoas
.
foo_module
.
Base_callDialogMethod
(
dialog_method
=
'Base_viewAsODS'
,
dialog_id
=
'Base_viewAsODSDialog'
,
form_id
=
'FooModule_viewFooList'
,
)
self
.
assertEqual
(
fake_request
.
get
(
'portal_skin'
),
'ODS'
)
self
.
assertEqual
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEqual
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
'application/csv'
)
expected_csv
=
'Title,Creation Date
\
n
foook2,XX/XX/XXXX XX:XX:XX
\
n
foook1,XX/XX/XXXX XX:XX:XX
\
n
'
self
.
assertEqual
(
len
(
result
),
len
(
expected_csv
),
result
)
prefix_length
=
len
(
'Title,Creation Date
\
n
foook2,'
)
self
.
assertEqual
(
result
[:
prefix_length
],
expected_csv
[:
prefix_length
])
@
changeSkin
(
'Hal'
)
def
test_getHateoas_exportAllViewCSV
(
self
,
**
kw
):
"""Check that ODS export returns views calculated from latest search
"""
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
ListBox_setPropertyList
(
field_columns
=
'
\
n
'
.
join
((
'id | ID'
,
'title | Title'
,
'creation_date | Creation Date'
,
)))
# Create the listbox selection
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"search"
,
# local_roles=["Manager"],
query
=
'title:"foook%"'
,
list_method
=
'searchFolder'
,
select_list
=
[
'title'
,
'creation_date'
,
'uid'
],
relative_url
=
'foo_module'
,
form_relative_url
=
'portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
,
sort_on
=
json
.
dumps
([
"title"
,
"descending"
])
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
2
)
# Export as CSV
fake_request
=
do_fake_request
(
"POST"
,
data
=
(
(
'dialog_method'
,
'Base_viewAsODS'
),
(
'dialog_id'
,
'Base_viewAsODSDialog'
),
(
'form_id'
,
'FooModule_viewFooList'
),
(
'selection_name'
,
'foo_selection'
),
(
'field_your_print_mode'
,
'list_view'
),
(
'default_field_your_print_mode:int'
,
'0'
),
(
'field_your_format'
,
'csv'
),
(
'default_field_your_format:int'
,
'0'
),
(
'field_your_target_language'
,
''
),
(
'default_field_your_target_language:int'
,
'0'
),
(
'extra_param_json'
,
'{}'
),
))
fake_portal
=
replace_request
(
fake_request
,
self
.
portal
)
result
=
fake_portal
.
web_site_module
.
hateoas
.
foo_module
.
Base_callDialogMethod
(
dialog_method
=
'Base_viewAsODS'
,
dialog_id
=
'Base_viewAsODSDialog'
,
form_id
=
'FooModule_viewFooList'
,
)
self
.
assertEqual
(
fake_request
.
get
(
'portal_skin'
),
'ODS'
)
self
.
assertEqual
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEqual
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
'application/csv'
)
self
.
assertTrue
(
'foook1'
in
result
,
result
)
self
.
assertTrue
(
'foook2'
in
result
,
result
)
self
.
assertTrue
(
'foonotok'
not
in
result
,
result
)
# Check one of the field name
self
.
assertTrue
(
'Read-Only Quantity'
in
result
,
result
)
# Ensure it is not the list mode rendering
self
.
assertTrue
(
len
(
result
.
split
(
'
\
n
'
))
>
50
,
result
)
bt5/erp5_hal_json_style/bt/test_dependency_list
View file @
17f5aec9
...
...
@@ -2,4 +2,5 @@ erp5_full_text_mroonga_catalog
erp5_ui_test_core
erp5_ui_test
erp5_dummy_movement
erp5_configurator_standard_trade_template
\ No newline at end of file
erp5_configurator_standard_trade_template
erp5_ods_style
\ No newline at end of file
bt5/erp5_ods_style/ActionTemplateItem/portal_types/portal_actions/ods_export.xml
View file @
17f5aec9
...
...
@@ -14,7 +14,7 @@
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_exchange
</string>
</value>
<value>
<string>
object_
jio_
exchange
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
...
...
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