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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
79456231
Commit
79456231
authored
Feb 05, 2020
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: Fix code to generate PDF from images taken
parent
6c23652c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
28 deletions
+49
-28
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
...ateItem/web_page_module/rjs_gadget_document_scanner_js.js
+28
-17
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
...teItem/web_page_module/rjs_gadget_document_scanner_js.xml
+2
-2
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_getTempImageList.py
...rtal_skins/erp5_document_scanner/Base_getTempImageList.py
+6
-4
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_getTempImageList.xml
...tal_skins/erp5_document_scanner/Base_getTempImageList.xml
+1
-1
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.py
...ns/erp5_document_scanner/Base_uploadDocumentFromCamera.py
+2
-2
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
...s/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
+1
-1
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCameraByActivity.py
...cument_scanner/Base_uploadDocumentFromCameraByActivity.py
+8
-0
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCameraByActivity.xml
...ument_scanner/Base_uploadDocumentFromCameraByActivity.xml
+1
-1
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
View file @
79456231
...
...
@@ -93,13 +93,13 @@
}
});
})
.
push
(
function
(
response
)
{
var
state_dict
=
{};
.
push
(
function
(
evt
)
{
var
state_dict
=
{},
data
=
JSON
.
parse
(
evt
.
target
.
responseText
);
state_dict
[
'
blob_state_
'
+
blob_page
]
=
'
OK
'
;
state_dict
[
'
blob_uuid_
'
+
blob_page
]
=
response
.
uuid
;
state_dict
[
'
blob_uuid_
'
+
blob_page
]
=
data
.
uuid
;
return
gadget
.
changeState
(
state_dict
);
},
function
()
{
// XXX TODO: Handle error case
var
state_dict
=
{};
state_dict
[
'
blob_state_
'
+
blob_page
]
=
'
error
'
;
return
gadget
.
changeState
(
state_dict
);
...
...
@@ -607,18 +607,29 @@
// Used when submitting the form
//////////////////////////////////////////////////
.
declareMethod
(
'
getContent
'
,
function
()
{
var
gadget
=
this
,
result
=
{};
// XXX TODO: check all blob, and only return the UUID for the one in stored state
result
.
data_json
=
JSON
.
stringify
({
active_process
:
gadget
.
state
.
active_process
,
image_list
:
gadget
.
state
.
image_list
});
result
[
gadget
.
state
.
key
]
=
JSON
.
stringify
({
input_value
:
'
XXX
'
,
preferred_cropped_canvas_data
:
gadget
.
state
.
preferred_cropped_canvas_data
});
throw
new
Error
(
'
not implemented getContent
'
);
var
key
,
uuid_key
,
result
,
gadget
=
this
,
image_list
=
[];
for
(
key
in
gadget
.
state
)
{
if
(
gadget
.
state
.
hasOwnProperty
(
key
))
{
if
(
key
.
indexOf
(
"
blob_state_
"
)
!==
-
1
&&
gadget
.
state
[
key
]
==
"
OK
"
)
{
uuid_key
=
"
blob_uuid_
"
+
key
.
replace
(
"
blob_state_
"
,
""
);
image_list
.
push
(
gadget
.
state
[
uuid_key
]);
}
}
}
result
=
{
data_json
:
JSON
.
stringify
({
active_process
:
gadget
.
state
.
active_process
,
image_list
:
image_list
,
preferred_cropped_canvas_data
:
gadget
.
state
.
preferred_cropped_canvas_data
})
};
return
result
;
},
{
mutex
:
'
changestate
'
})
.
declareMethod
(
'
checkValidity
'
,
function
()
{
...
...
@@ -628,7 +639,7 @@
for
(
key
in
gadget
.
state
)
{
if
(
gadget
.
state
.
hasOwnProperty
(
key
))
{
if
(
key
.
indexOf
(
"
blob_state_
"
)
!==
-
1
&&
!
gadget
.
state
[
key
].
match
(
"
deleted|
stored
"
))
{
!
gadget
.
state
[
key
].
match
(
"
deleted|
OK
"
))
{
return
false
;
}
if
(
key
.
indexOf
(
"
blob_url_
"
)
!==
-
1
)
{
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
View file @
79456231
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
981.4
0903.42421.64529
</string>
</value>
<value>
<string>
981.4
2511.4469.1024
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1580
845018.98
</float>
<float>
1580
940947.83
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_getTempImageList.py
View file @
79456231
"""
Proxy role as Manager is required here to access getResultList
"""
from
base64
import
decodestring
if
REQUEST
:
return
RuntimeError
(
"You cannot run this script in the url"
)
...
...
@@ -8,9 +9,10 @@ image_module = context.getPortalObject().image_module
pdf_data_list
=
[]
for
result
in
active_process
.
getResultList
():
pdf_data_list
.
append
(
image_module
.
newContent
(
data
=
result
.
detail
,
portal_type
=
"Image"
,
temp_object
=
True
).
convert
(
format
=
"pdf"
)[
1
])
if
result
.
reference
in
image_list
:
pdf_data_list
.
append
(
image_module
.
newContent
(
data
=
decodestring
(
result
.
detail
),
portal_type
=
"Image"
,
temp_object
=
False
).
convert
(
format
=
"pdf"
)[
1
])
return
pdf_data_list
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_getTempImageList.xml
View file @
79456231
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
active_process, REQUEST=None
</string>
</value>
<value>
<string>
active_process,
image_list,
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.py
View file @
79456231
...
...
@@ -5,9 +5,9 @@ class StringIOWithFileName(StringIO):
kw
.
get
(
"title"
)
or
DateTime
().
strftime
(
'%d-%m-%Y_%Hh%M'
))
portal
=
context
.
getPortalObject
()
active_process
=
portal
.
restrictedTraverse
(
active_process_url
)
active_process
=
portal
.
restrictedTraverse
(
str
(
active_process_url
)
)
pdf_data_list
=
context
.
Base_getTempImageList
(
active_process
)
pdf_data_list
=
context
.
Base_getTempImageList
(
active_process
,
image_list
)
pdf_data
=
context
.
ERP5Site_mergePDFList
(
pdf_data_list
=
pdf_data_list
)
file_object
=
StringIOWithFileName
(
pdf_data
)
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
View file @
79456231
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
publication_state, active_process_url
=None
, **kw
</string>
</value>
<value>
<string>
publication_state, active_process_url
, image_list
, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCameraByActivity.py
View file @
79456231
import
json
data_dict
=
json
.
loads
(
data_json
)
portal
=
context
.
getPortalObject
()
translateString
=
portal
.
Base_translateString
active_process_url
=
data_dict
.
pop
(
"active_process"
)
image_list
=
data_dict
.
pop
(
"image_list"
)
# Avoid to pass huge images to the activity
kw
.
pop
(
"your_document_scanner_gadget"
,
None
)
context
.
activate
().
Base_uploadDocumentFromCamera
(
publication_state
=
publication_state
,
active_process_url
=
active_process_url
,
image_list
=
image_list
,
**
kw
)
return
context
.
Base_redirect
(
'view'
,
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCameraByActivity.xml
View file @
79456231
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
active_process_url=Non
e, **kw
</string>
</value>
<value>
<string>
data_json, publication_stat
e, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</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