Commit 5d08412f authored by Romain Courteaud's avatar Romain Courteaud

Prevent cutting documents which have related documents, in order to keep the relations consistent.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11690 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fc94f562
...@@ -68,22 +68,56 @@ ...@@ -68,22 +68,56 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n N_ = portal.Base_translateString\n
\n \n
def Object_hasRelation(object):\n
# Check if there is some related objets.\n
result = 0\n
for o in object.getIndexableChildValueList():\n
for related in object.portal_categories.getRelatedValueList(object):\n
if related.getRelativeUrl().startswith(object.getRelativeUrl()):\n
continue\n
elif related.getRelativeUrl().startswith(\'portal_simulation\') :\n
continue\n
else:\n
result = 1\n
break\n
return result\n
\n
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)\n selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)\n
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)\n uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)\n
# make sure nothing is checked after\n # make sure nothing is checked after\n
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])\n context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])\n
request=context.REQUEST\n request=context.REQUEST\n
\n \n
\n
\n
if uids != []:\n if uids != []:\n
context.manage_cutObjects(uids=uids, REQUEST=request)\n # Check if there is some related objets.\n
message = N_("Item(s)+Cut.")\n object_used = 0\n
\n
object_list = [x.getObject() for x in context.portal_catalog(uid=uids)]\n
object_used = sum([Object_hasRelation(x) for x in object_list])\n
\n
if object_used > 0:\n
if object_used == 1:\n
message = N_("Sorry,+1+Item+Is+In+Use.")\n
else:\n
message = N_("Sorry,+${count}+Items+Are+In+Use.",\n
mapping={\'count\': repr(object_used)})\n
qs = \'?portal_status_message=%s\' % message \n
else:\n
context.manage_cutObjects(uids=uids, REQUEST=request)\n
message = N_("Item(s)+Cut.")\n
else:\n else:\n
message = N_("Please+select+one+or+more+items+to+cut+first.")\n message = N_("Please+select+one+or+more+items+to+cut+first.")\n
return request.RESPONSE.redirect(context.absolute_url() + \'/\' + form_id + \'?portal_status_message=%s\' % message)\n return request.RESPONSE.redirect(context.absolute_url() + \'/\' + form_id + \'?portal_status_message=%s\' % message)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -133,9 +167,19 @@ return request.RESPONSE.redirect(context.absolute_url() + \'/\' + form_id + \'?p ...@@ -133,9 +167,19 @@ return request.RESPONSE.redirect(context.absolute_url() + \'/\' + form_id + \'?p
<string>context</string> <string>context</string>
<string>portal</string> <string>portal</string>
<string>N_</string> <string>N_</string>
<string>Object_hasRelation</string>
<string>selected_uids</string> <string>selected_uids</string>
<string>request</string> <string>request</string>
<string>object_used</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>object_list</string>
<string>sum</string>
<string>message</string> <string>message</string>
<string>repr</string>
<string>qs</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
213 215
\ 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