diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createNewFile.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createNewFile.xml index 18d46dfb00ab2caa6cd784e7ca4c8b029bf15b1e..93c1f1b1c354ba4d4e748d568f617a37a0fa7381 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createNewFile.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createNewFile.xml @@ -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> diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog.xml index c9cdf342719f040213b29566006aedb807e00f87..6b81c955567a1323306bef1ad7a6a52cb88d1883 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog.xml @@ -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> diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog/your_portal_type.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog/your_portal_type.xml index 31d86333633a42909f278ff0fd9423ac8173b4a5..7a0434d8683b76593d22b7fabcb19aed1baaf074 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog/your_portal_type.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_viewNewFileDialog/your_portal_type.xml @@ -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> diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 6efca19ea0b6814902678d61d3b643d78797c000..d9bf67ee84b44af7037f0cd8890f93153fad21cb 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -481 \ No newline at end of file +484 \ No newline at end of file