Commit 82cf3205 authored by Jérome Perrin's avatar Jérome Perrin

Checks that a same object has the context can be added in the container using

visible content types in Base_createNewDocument. If the content is an hidden
allowed content type, refuse to create a new document of this type.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10869 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4cfb7d13
...@@ -68,26 +68,34 @@ ...@@ -68,26 +68,34 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>N_ = context.getPortalObject().Base_translateString\n <value> <string>"""Add an object of the same type as self in the container, unless\n
this type cannot be added in the container.\n
"""\n
N_ = context.getPortalObject().Base_translateString\n
REQUEST=context.REQUEST\n REQUEST=context.REQUEST\n
\n
# Add an object of the same type as self in the container.\n
parent = context.aq_parent\n parent = context.aq_parent\n
allowed_type_list = parent.getVisibleAllowedContentTypeList()\n
\n
if not allowed_type_list:\n
return context.ERP5Site_redirect(\'%s/%s/view\' % (\n
parent.getUrl(), context.getId()),\n
keep_items={\'portal_status_message\':\n
N_("You are not allowed to add new content in this context.")})\n
\n \n
# XXX May be this need to be changed in order to get something else than\n if context.getPortalType() not in allowed_type_list:\n
# the permission "Add portal content"\n return context.ERP5Site_redirect(\'%s/%s/view\' % (\n
if not parent.allowedContentTypes():\n parent.getUrl(), context.getId()),\n
return context.ERP5Site_redirect(\'%s/%s/view\' % (parent.getUrl(), context.getId()), \n keep_items={\'portal_status_message\':\n
keep_items={\'portal_status_message\': N_("You are not allowed to add new content in this context.")})\n N_("You are not allowed to add ${portal_type} in this context.",\n
mapping=dict(portal_type=context.getTranslatedPortalType()))})\n
\n \n
else:\n new_id = parent.generateNewId()\n
new_id = parent.generateNewId()\n context.portal_types.constructContent(type_name=context.portal_type,\n
context.portal_types.constructContent(type_name=context.portal_type,\n container=parent,\n
container=parent,\n id=str(new_id),\n
id=str(new_id),\n RESPONSE=REQUEST.RESPONSE)\n
RESPONSE=REQUEST.RESPONSE)\n return context.ERP5Site_redirect(\'%s/%s/view\' % (parent.getUrl(), new_id),\n
return context.ERP5Site_redirect(\'%s/%s/view\' % (parent.getUrl(), new_id), \n keep_items={\'portal_status_message\': N_("Object Created.")})\n
keep_items={\'portal_status_message\': N_("Object Created.")})\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -96,6 +104,12 @@ else:\n ...@@ -96,6 +104,12 @@ else:\n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <value>
...@@ -135,6 +149,8 @@ else:\n ...@@ -135,6 +149,8 @@ else:\n
<string>N_</string> <string>N_</string>
<string>REQUEST</string> <string>REQUEST</string>
<string>parent</string> <string>parent</string>
<string>allowed_type_list</string>
<string>dict</string>
<string>new_id</string> <string>new_id</string>
<string>str</string> <string>str</string>
</tuple> </tuple>
...@@ -164,4 +180,25 @@ else:\n ...@@ -164,4 +180,25 @@ else:\n
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
276 277
\ 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