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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
e0ef72d5
Commit
e0ef72d5
authored
Sep 16, 2019
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: Add script to upload
parent
caf71994
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
0 deletions
+136
-0
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.py
...ns/erp5_document_scanner/Base_uploadDocumentFromCamera.py
+70
-0
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
...s/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
+66
-0
No files found.
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.py
0 → 100644
View file @
e0ef72d5
"""
Use to contribute file to ERP5.
"""
from
base64
import
decodestring
portal
=
context
.
getPortalObject
()
translateString
=
portal
.
Base_translateString
MARKER
=
[
''
,
None
]
portal_contributions
=
portal
.
portal_contributions
context_url
=
context
.
getRelativeUrl
()
if
synchronous_metadata_discovery
is
None
:
synchronous_metadata_discovery
=
portal
.
portal_preferences
.
isPreferredSynchronousMetadataDiscovery
(
False
)
user_login
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getId
()
document_kw
=
{
'user_login'
:
user_login
,
'group'
:
group
,
'publication_section'
:
publication_section
}
if
portal_type
not
in
MARKER
:
document_kw
[
'portal_type'
]
=
portal_type
document_kw
[
'default_follow_up_uid'
]
=
context
.
getUid
()
for
key
in
(
'title'
,
'short_title'
,
'reference'
,
'language'
,
'version'
,
'description'
):
value
=
kw
.
get
(
key
,
None
)
if
value
not
in
MARKER
:
document_kw
[
key
]
=
value
document_kw
.
update
({
'discover_metadata'
:
not
synchronous_metadata_discovery
})
# contribute file
document_kw
.
update
({
'data'
:
decodestring
(
document_scanner_gadget
),
"filename"
:
"{}.png"
.
format
(
document_kw
.
get
(
"title"
)
or
document_scanner_gadget
[:
10
])
})
document
=
portal_contributions
.
newContent
(
**
document_kw
)
is_existing_document_updated
=
False
if
synchronous_metadata_discovery
:
# we need to do all synchronously, in other case portal_contributions will do
# this in an activity
if
document
.
isSupportBaseDataConversion
():
document
.
processFile
()
filename
=
document
.
getFilename
()
merged_document
=
document
.
Document_convertToBaseFormatAndDiscoverMetadata
(
filename
=
filename
,
user_login
=
user_login
,
input_parameter_dict
=
document_kw
)
is_existing_document_updated
=
(
merged_document
!=
document
)
document
=
merged_document
document_portal_type
=
document
.
getTranslatedPortalType
()
if
not
is_existing_document_updated
:
message
=
translateString
(
'${portal_type} created successfully.'
,
mapping
=
dict
(
portal_type
=
document_portal_type
))
else
:
message
=
translateString
(
'${portal_type} updated successfully.'
,
mapping
=
dict
(
portal_type
=
document_portal_type
))
if
batch_mode
:
return
document
return
document
.
Base_redirect
(
'view'
,
keep_items
=
{
'portal_status_message'
:
message
,
'editable_mode'
:
editable_mode
})
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/Base_uploadDocumentFromCamera.xml
0 → 100644
View file @
e0ef72d5
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
portal_type=None, classification=None, synchronous_metadata_discovery=None, cancel_url=None, batch_mode=False, editable_mode=1, group=None, publication_section=None, document_scanner_gadget=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_uploadDocumentFromCamera
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Contribute file or url to ERP5
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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