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
Tristan Cavelier
erp5
Commits
99f0744c
Commit
99f0744c
authored
Jan 26, 2017
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_base: add Convert To scripts
parent
f27c534f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
823 additions
and
0 deletions
+823
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_convertToNewContent.py
...teItem/portal_skins/erp5_base/Base_convertToNewContent.py
+65
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_convertToNewContent.xml
...eItem/portal_skins/erp5_base/Base_convertToNewContent.xml
+62
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog.xml
...al_skins/erp5_base/Base_viewConvertToNewContentDialog.xml
+132
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog/your_destination_mimetype.xml
...ewConvertToNewContentDialog/your_destination_mimetype.xml
+277
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog/your_version.xml
..._base/Base_viewConvertToNewContentDialog/your_version.xml
+287
-0
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_convertToNewContent.py
0 → 100644
View file @
99f0744c
portal
=
context
.
getPortalObject
()
content_type
=
context
.
getContentType
()
def
splitext
(
unixpath
):
slashsplit
=
unixpath
.
split
(
"/"
)
dotsplit
=
slashsplit
[
-
1
].
split
(
"."
)
reqlen
=
3
if
dotsplit
[
0
]
==
''
else
2
if
len
(
dotsplit
)
<
reqlen
:
return
(
unixpath
,
''
)
return
(
'/'
.
join
(
slashsplit
[:
-
1
]
+
[
'.'
.
join
(
dotsplit
[:
-
1
])]),
'.'
+
dotsplit
[
-
1
])
def
getTargetFormatItemList
(
content_type
):
# returns [(title, mimetype), ...]
if
content_type
is
None
:
return
[]
format_list
=
[]
available_mimetype_list
=
portal
.
portal_transforms
.
getAvailableTargetMimetypeList
(
content_type
)
mimetype_registry
=
portal
.
mimetypes_registry
for
available_mimetype
in
available_mimetype_list
:
mimetype_info_list
=
mimetype_registry
.
lookup
(
available_mimetype
)
for
mimetype_info
in
mimetype_info_list
:
format_list
.
append
((
mimetype_info
.
name
(),
available_mimetype
))
return
format_list
def
getExtension
(
content_type
,
default
=
None
):
for
info
in
portal
.
mimetypes_registry
.
lookup
(
content_type
):
try
:
return
info
.
extensions
[
0
]
except
IndexError
:
pass
return
default
if
__list
:
if
content_type
in
(
""
,
None
):
return
[]
#return getTargetFormatItemList(content_type)
#return [("%s (%s)" %(t, mt), mt) for t, mt in getTargetFormatItemList(content_type)]
return
[(
"%s (%s)"
%
(
t
,
getExtension
(
mt
,
"-"
)),
mt
)
for
t
,
mt
in
getTargetFormatItemList
(
content_type
)]
destination_portal_type
=
portal
.
portal_contribution_registry
.
findPortalTypeName
(
content_type
=
destination_mimetype
)
module_id
=
portal
.
getDefaultModuleId
(
destination_portal_type
,
default
=
None
,
only_visible
=
True
)
extension
=
getExtension
(
destination_mimetype
,
"bin"
)
data
=
portal
.
portal_transforms
.
convertToData
(
destination_mimetype
,
str
(
context
.
getData
()
or
""
),
context
=
context
,
mimetype
=
content_type
)
if
data
is
None
:
raise
ValueError
(
"Failed to convert to %r"
%
destination_mimetype
)
document
=
portal
[
module_id
].
newContent
(
portal_type
=
destination_portal_type
,
title
=
context
.
getTitle
(),
short_title
=
context
.
getShortTitle
(),
reference
=
context
.
getReference
(),
version
=
version
,
language
=
context
.
getLanguage
(),
effective_date
=
context
.
getEffectiveDate
(),
filename
=
splitext
(
context
.
getFilename
(
'untitled'
))[
0
]
+
"."
+
extension
,
content_type
=
destination_mimetype
,
data
=
data
,
category_list
=
context
.
getCategoryList
(),
description
=
context
.
getDescription
(),
)
if
REQUEST
is
None
:
return
document
return
document
.
Base_redirect
(
keep_items
=
{
"portal_status_message"
:
context
.
Base_translateString
(
"Converted successfully"
)})
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_convertToNewContent.xml
0 → 100644
View file @
99f0744c
<?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>
destination_mimetype=\'\', version=None, __list=False, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_convertToNewContent
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog.xml
0 → 100644
View file @
99f0744c
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ERP5 Form"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
Base_convertToNewContent
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
edit_order
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
enctype
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
group_list
</string>
</key>
<value>
<list>
<string>
left
</string>
<string>
right
</string>
<string>
center
</string>
<string>
bottom
</string>
<string>
hidden
</string>
</list>
</value>
</item>
<item>
<key>
<string>
groups
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
bottom
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
center
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
your_destination_mimetype
</string>
<string>
your_version
</string>
</list>
</value>
</item>
<item>
<key>
<string>
right
</string>
</key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_viewConvertToNewContentDialog
</string>
</value>
</item>
<item>
<key>
<string>
method
</string>
</key>
<value>
<string>
POST
</string>
</value>
</item>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
Base_viewConvertToNewContentDialog
</string>
</value>
</item>
<item>
<key>
<string>
pt
</string>
</key>
<value>
<string>
form_dialog
</string>
</value>
</item>
<item>
<key>
<string>
row_length
</string>
</key>
<value>
<int>
4
</int>
</value>
</item>
<item>
<key>
<string>
stored_encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Convert Document
</string>
</value>
</item>
<item>
<key>
<string>
unicode_mode
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
update_action
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
update_action_title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog/your_destination_mimetype.xml
0 → 100644
View file @
99f0744c
This diff is collapsed.
Click to expand it.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewConvertToNewContentDialog/your_version.xml
0 → 100644
View file @
99f0744c
This diff is collapsed.
Click to expand it.
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