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
...@@ -54,51 +54,49 @@ ...@@ -54,51 +54,49 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>translateString = context.Base_translateString\n <value> <string>translateString = context.Base_translateString\n
from Products.CMFCore.utils import getToolByName\n
\n \n
# XXX Current there is no Group or Portal Type specific to define\n if file.filename not in [\'\', None]:\n
# Embedded portal types. It will leave it hardcoded until a \n
# good API be defined.\n
\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 \n
module_id = context.getDefaultModuleId(portal_type, \'\')\n container = getToolByName(context.getPortalObject(), \'portal_contributions\', None)\n
module = getattr(context, module_id, None)\n
\n \n
if module is not None:\n is_authorized = 1\n
allowed_type_list = module.getVisibleAllowedContentTypeList()\n if container is None:\n
if portal_type not in allowed_type_list:\n container = context\n
return context.Base_redirect(\n document_new_content_kw[\'portal_type\'] = portal_type\n
keep_items={\'portal_status_message\':\n if portal_type not in [\'%s\' % x.id for x in container.allowedContentTypes()]:\n
translateString("You are not allowed to create this object.")})\n is_authorized = 0\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
\n \n
if not context.Base_checkPermission(container.getRelativeUrl(),\n
\'Add portal content\'):\n
is_authorized = 0\n
\n \n
document = module.newContent( portal_type=portal_type,\n if not is_authorized:\n
description=description,\n return context.Base_redirect(\n
title=title)\n keep_items={\'portal_status_message\':\n
\n translateString(\n
# XXX If DMS exist?\n "You are not allowed to create this object.")})\n
document.edit(follow_up=context.getRelativeUrl(),\n
version=version,\n
short_title=short_title,\n
language=language,\n
reference=reference)\n
\n \n
if file.filename not in [\'\', None]:\n document = container.newContent(**document_new_content_kw)\n
document.setFile(file)\n document.edit(**document_edit_kw)\n
\n \n
message = translateString(\'${portal_type} created successfully.\',\n message = translateString(\'${portal_type} created successfully.\',\n
mapping={\'portal_type\':document.getTranslatedPortalType()})\n mapping={\'portal_type\': document.getTranslatedPortalType()})\n
return context.REQUEST.RESPONSE.redirect(\n return document.Base_redirect(\'view\', \n
\'%s/view?portal_status_message=%s\' % (document.absolute_url(), message)\n keep_items=dict(portal_status_message=message))\n
)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -148,14 +146,22 @@ return context.REQUEST.RESPONSE.redirect(\n ...@@ -148,14 +146,22 @@ return context.REQUEST.RESPONSE.redirect(\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>translateString</string> <string>translateString</string>
<string>embedded_portal_type_list</string> <string>Products.CMFCore.utils</string>
<string>module_id</string> <string>getToolByName</string>
<string>getattr</string>
<string>None</string> <string>None</string>
<string>module</string> <string>document_new_content_kw</string>
<string>allowed_type_list</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>document</string>
<string>message</string> <string>message</string>
<string>dict</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -83,7 +83,9 @@ ...@@ -83,7 +83,9 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list/> <list>
<string>your_description</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -96,12 +98,7 @@ ...@@ -96,12 +98,7 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_portal_type</string> <string>your_file</string>
<string>your_title</string>
<string>your_short_title</string>
<string>your_reference</string>
<string>your_language</string>
<string>your_version</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -109,8 +106,12 @@ ...@@ -109,8 +106,12 @@
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list>
<string>your_file</string> <string>your_portal_type</string>
<string>your_description</string> <string>your_title</string>
<string>your_short_title</string>
<string>your_reference</string>
<string>your_language</string>
<string>your_version</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>required</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
481 484
\ No newline at end of file \ 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