Commit 74af30c8 authored by Romain Courteaud's avatar Romain Courteaud

Rewrite Base_createNewFile in order to use contribution tool if it exists.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24755 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 701c6baf
No related merge requests found
......@@ -54,51 +54,49 @@
<item>
<key> <string>_body</string> </key>
<value> <string>translateString = context.Base_translateString\n
from Products.CMFCore.utils import getToolByName\n
\n
# XXX Current there is no Group or Portal Type specific to define\n
# Embedded portal types. It will leave it hardcoded until a \n
# good API be defined.\n
if file.filename not in [\'\', None]:\n
\n
embedded_portal_type_list = ["File", "Image"] \n
document_new_content_kw = {\n
\'file\': file,\n
}\n
document_edit_kw = {\n
\'follow_up\': context.getRelativeUrl(),\n
\'version\': version,\n
\'title\': title,\n
\'short_title\': short_title,\n
\'language\': language,\n
\'reference\': reference,\n
\'description\': description,\n
}\n
\n
module_id = context.getDefaultModuleId(portal_type, \'\')\n
module = getattr(context, module_id, None)\n
container = getToolByName(context.getPortalObject(), \'portal_contributions\', None)\n
\n
if module is not None:\n
allowed_type_list = module.getVisibleAllowedContentTypeList()\n
if portal_type not in allowed_type_list:\n
return context.Base_redirect(\n
keep_items={\'portal_status_message\':\n
translateString("You are not allowed to create this object.")})\n
else:\n
module = context\n
if ((portal_type not in embedded_portal_type_list) and\n
(context.Base_checkPermission(context.getRelativeUrl(),\n
\'Add portal content\'))):\n
return context.Base_redirect(\n
keep_items={\'portal_status_message\':\n
translateString("You are not allowed to create this object.")})\n
is_authorized = 1\n
if container is None:\n
container = context\n
document_new_content_kw[\'portal_type\'] = portal_type\n
if portal_type not in [\'%s\' % x.id for x in container.allowedContentTypes()]:\n
is_authorized = 0\n
\n
if not context.Base_checkPermission(container.getRelativeUrl(),\n
\'Add portal content\'):\n
is_authorized = 0\n
\n
document = module.newContent( portal_type=portal_type,\n
description=description,\n
title=title)\n
\n
# XXX If DMS exist?\n
document.edit(follow_up=context.getRelativeUrl(),\n
version=version,\n
short_title=short_title,\n
language=language,\n
reference=reference)\n
if not is_authorized:\n
return context.Base_redirect(\n
keep_items={\'portal_status_message\':\n
translateString(\n
"You are not allowed to create this object.")})\n
\n
if file.filename not in [\'\', None]:\n
document.setFile(file)\n
document = container.newContent(**document_new_content_kw)\n
document.edit(**document_edit_kw)\n
\n
message = translateString(\'${portal_type} created successfully.\',\n
mapping={\'portal_type\':document.getTranslatedPortalType()})\n
return context.REQUEST.RESPONSE.redirect(\n
\'%s/view?portal_status_message=%s\' % (document.absolute_url(), message)\n
)\n
message = translateString(\'${portal_type} created successfully.\',\n
mapping={\'portal_type\': document.getTranslatedPortalType()})\n
return document.Base_redirect(\'view\', \n
keep_items=dict(portal_status_message=message))\n
</string> </value>
</item>
<item>
......@@ -148,14 +146,22 @@ return context.REQUEST.RESPONSE.redirect(\n
<string>_getattr_</string>
<string>context</string>
<string>translateString</string>
<string>embedded_portal_type_list</string>
<string>module_id</string>
<string>getattr</string>
<string>Products.CMFCore.utils</string>
<string>getToolByName</string>
<string>None</string>
<string>module</string>
<string>allowed_type_list</string>
<string>document_new_content_kw</string>
<string>document_edit_kw</string>
<string>container</string>
<string>is_authorized</string>
<string>_write_</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>_apply_</string>
<string>document</string>
<string>message</string>
<string>dict</string>
</tuple>
</value>
</item>
......
......@@ -83,7 +83,9 @@
<item>
<key> <string>center</string> </key>
<value>
<list/>
<list>
<string>your_description</string>
</list>
</value>
</item>
<item>
......@@ -96,12 +98,7 @@
<key> <string>left</string> </key>
<value>
<list>
<string>your_portal_type</string>
<string>your_title</string>
<string>your_short_title</string>
<string>your_reference</string>
<string>your_language</string>
<string>your_version</string>
<string>your_file</string>
</list>
</value>
</item>
......@@ -109,8 +106,12 @@
<key> <string>right</string> </key>
<value>
<list>
<string>your_file</string>
<string>your_description</string>
<string>your_portal_type</string>
<string>your_title</string>
<string>your_short_title</string>
<string>your_reference</string>
<string>your_language</string>
<string>your_version</string>
</list>
</value>
</item>
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>size</string> </key>
......@@ -275,7 +275,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:map(lambda x: (here.Localizer.erp5_ui.gettext(x), x), here.getPortalDocumentTypeList())</string> </value>
<value> <string>python: [(\'\', \'\')]+[(here.Base_translateString(x), x) for x in here.getPortalDocumentTypeList()]</string> </value>
</item>
</dictionary>
</pickle>
......
481
\ No newline at end of file
484
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment